if i have the handle (hwnd) to a control or a window i've painted and image onto. how do i get that image and save it to a file using the handle.
any tips or links would be appreciated. thanks in advance :)
Hi,
If you painted the image, you probably have the image handle too. There must some way of making it into a file. No need of window handle. Unless you need to get the hDc of the window or something.
Thomas
It is possible using GDIplus.dll, if you like to have a look at it.. The way to do it is something like this:
(This does NOT work!)
Invoke GdipCreateFromHWND,hWnd,ADDR hGraphics
Invoke GetClientRect,hWnd,ADDR rct
Invoke GdipCreateBitmapFromGraphics,rct.right,rct.bottom,hGraphics,ADDR hBitmap
Invoke GdipGetImageEncodersSize,ADDR encoderNums,ADDR arraySize
**Need to allocate memory for encoders here
Invoke GdipGetImageEncoders,numEncoders,SIZE,ADDR encoders
Invoke GdipSaveImageToFile,hBitmap,ADDR szWFileName,clsidEncoder,encoderParams
The problem is to get the clsidEncoder, i did not try to do it in asm, but have a working function in VB6.
AFAIK, GDIplus supports saving as bmp-, png-, tiff-, jpg- and gif-formats. With VB6, i have tested png, bmp and gif.
Regards, phoenix