Windows GDI Programming

Programming, for all ages and all languages.
Post Reply
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Windows GDI Programming

Post 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?
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Windows GDI Programming

Post 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.
My OS is Perception.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post 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.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
Post Reply