I'm trying to use StretchBlt for resizing an image, but I'm missing something.
I believe that StartDrawing returns a hDC and ImageID returns a HBITMAP, could anyone tell me why the following code doesn't work?
Code: Select all
Procedure SizeImage(image, w, h)
Protected newimg, srcobject, dstobject, srcDC, dstDC
newimg = CreateImage(#PB_Any, w, h) ;create the new image at the requested size
;device contexts
dstDC = StartDrawing(ImageOutput(newimg))
srcDC = CreateCompatibleDC_(dstDC)
;select bitmaps
srcobject = SelectObject_(srcDC, ImageID(image))
;dstobject = SelectObject_(dstDC, ImageID(newimg))
StretchBlt_(dstDC, 0, 0, w, h, srcDC, 0, 0, ImageWidth(image), ImageHeight(image), #SRCCOPY)
;SelectObject_(dstDC, dstobject)
SelectObject_(srcDC, srcobject)
StopDrawing()
DeleteDC_(srcDC)
ProcedureReturn newimg
EndProcedure