News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Saving image from handle

Started by Ash_, April 09, 2005, 10:47:31 AM

Previous topic - Next topic

Ash_

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 :)

thomasantony

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
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

Phoenix

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