Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting from HBITMAP to Jpeg or Png in C++

Does anyone know how I can use an HBITMAP variable to write a png or jpeg file?

I first looked into doing this with GDI+ but it gives me errors telling me min/max haven't been defined (defining them just brings more problems), I then looked into libpng's C++ bindings (png++) and couldn't get the examples to compile.

thanks,

Mikey

like image 624
Mikey Avatar asked Oct 07 '09 16:10

Mikey


1 Answers

HBITMAP bmp;
CImage image;
image.Attach(bmp);
image.Save("filename.jpg"); // change extension to save to png
like image 60
Nikola Smiljanić Avatar answered Oct 22 '22 14:10

Nikola Smiljanić