CopyImage_ doesn't resize image
Posted: Tue Jul 30, 2024 12:42 pm
I used the post at > https://www.purebasic.fr/english/viewto ... daa2f60adb > the code by RASHAD to derive the below:
The 'icon' is displayed on the button but the image is not resized to 32 x 16 but rather is made square which ruins its 'aspect ratio' look.
To experiment, I also tried to set it as the window icon with this:
...and it set the window icon fine but its size is stretched vertically when it should have been 16 x 16 which is square so it appeared as a rectangle instead of square
What am I doing wrong to resize this image properly? Am I doing this wrong?
(Windows 10 pro system, PureBasic 6.11 LTS (Windows - x64) )
Code: Select all
UsePNGImageDecoder()
#IMAGE_ICON = 1
CatchImage(100, ?myimage)
pcon.ICONINFO
pcon\fIcon = #True
pcon\hbmMask = ImageID(100)
pcon\hbmColor = ImageID(100)
hIcon = CreateIconIndirect_(pcon)
hIcon = CopyImage_(hIcon,#IMAGE_ICON,32,16,#LR_COPYDELETEORG) ;Change size to 32 x 16
FreeImage(101)
< begin other window making/display code here ... If OpenWindow(0, ....etc...>
ImageGadget(1,100,20,32,16,hIcon)
<end other window making/display code here>
DataSection
myimage: : IncludeBinary "D:\Test\myimage.png" ; where myimage.png original size is 64 x 32
EndDataSection
To experiment, I also tried to set it as the window icon with this:
Code: Select all
<...same other code here for structure, window, etc.. except I changed to this to experiment and didn't use the button...>
hIcon = CopyImage_(hIcon,#IMAGE_ICON,16,16,#LR_COPYDELETEORG) ;Change size to 16 x 16
SendMessage_(WindowID(0), #WM_SETICON, 0, hIcon)
What am I doing wrong to resize this image properly? Am I doing this wrong?
(Windows 10 pro system, PureBasic 6.11 LTS (Windows - x64) )