Page 1 of 1

Windows GDI Programming

Posted: Thu May 24, 2007 4:27 am
by pcmattman
OK, I have this program that can take the desktop and shove it into a HBITMAP. Now I'm stuck, I want to save this as a PNG but I don't know how.

I've heard that GDI+ can help me out here, can anyone give me any pointers?

Re: Windows GDI Programming

Posted: Thu May 24, 2007 4:35 am
by AndrewAPrice
pcmattman wrote:OK, I have this program that can take the desktop and shove it into a HBITMAP. Now I'm stuck, I want to save this as a PNG but I don't know how.

I've heard that GDI+ can help me out here, can anyone give me any pointers?
Scroll down this article a bit: http://www.codeproject.com/cpp/Desktop_Calendar.asp

Then use paint, Photoshop, the Gimp, or Paint .Net to export it as a PNG.

Posted: Thu May 24, 2007 11:20 am
by XCHG
Well if you have the handle of the bitmap in the HBITMAP, then you can convert it into a PNG in two ways:

1) If you know the format of PNG images, you can simply use the GetDIBits() Win32 API defined in the GDI32.dll file in order to retrieve the BITMAP image and then convert it to a PNG.

2) Download third party components or find source codes in your chosen programming language in here

You can also get a good feedback in AsmCommunity.

I hope that helped. Good luck.