|
-
Aug 20th, 2001, 02:41 AM
#1
Thread Starter
Lively Member
BMP equivalent to LoadImageBynum and DrawIconEx?
The following two lines of code place an Icon in a PictureBox. The Icon is re-sized to fit the PictureBox (this is the important part).
ImageHandle = LoadImageBynum(0, IDI_WINLOGO, IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR Or LR_DEFAULTSIZE Or LR_SHARED)
Ret = DrawIconEx(Picture1.hdc, 0, 0, ImageHandle, Picture1.ScaleWidth, Picture1.ScaleHeight, 0, 0, DI_NORMAL)
What is the equivalent for a .BMP picture (either load from disk, or from another Image or PictureBox Control)?
Thanks,
-
Aug 20th, 2001, 04:23 PM
#2
Frenzied Member
The StretchBlt API is probably the best way to resize a bitmap. Bitmaps don't resize well but it will do it no problem.
Public Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
Declare Function StretchBlt Lib "gdi32" Alias "StretchBlt" (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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
StretchBlt takes gobs of paramters but if you think about it they are pretty straight forward.
hdc = Destination
x, y = X and Y of Dest
nWidth, nHeight = Height and width of what you want the dest to be in pixels
hSrcDC = Source
xSrc, ySrc = X and Y of the source
nSrcWidth, nSrcHeight =Height and width of the source in pixels
dwRop =SRCCOPY
If your source image is 32 X 32 Pixels you would set nSrcWidth and nSrcHeight to 32. If you wanted to stretch it out to twice it's size (64 X 64) you would set nWidth, nHeight both to 64.
Conversly you could shrink a 32 X 32 image by setting nWidth, nHeight to 16 and 16.
Greg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|