medleyj
May 9th, 2001, 09:59 AM
Does anybody know if there is a way to scale an image on a PictureBox control? Let me clarify this question a little bit. When the Control changes size, the image on the control also has to change size.
Thanks in advance.
Iouri
May 9th, 2001, 11:14 AM
Try this
Picture1 is a picture box the size of your exisitng icon
picture 2 is a picture the size you want it to be
picture2.AutoRedraw is TRUE
you can easily use this to re-size icons, bitmaps, jpeg's etc - could put this in your code, but I would
use it to resize your icon once, then use the result
the result is always a bitmap though.
Option Explicit
Private Sub Command1_Click()
Dim retval As Long
retval = StretchBlt(Picture2.hdc, 0, 0, Picture2.Width \ 15, Picture2.Height \ 15, _
Picture1.hdc, 0, 0, Picture1.Width \ 15, Picture1.Height \ 15, SRCCOPY)
SavePicture Picture2.Image, "c:\newpic.bmp"
Picture2.Refresh
End Sub
'in a .bas
Option Explicit
Public Const SRCCOPY = &HCC0020
Declare Function StretchBlt Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal
nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long,
ByVal hSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
Declare Function BitBlt Lib "gdi32.dll" (ByVal hdcDest As Long, ByVal nXDest As Long, ByVal nYDest As
Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal
nYSrc As Long, ByVal dwRop As Long) As Long
Iouri Boutchkine
iouri@hotsheet.com