开发者

Converting from HBITMAP to Jpeg or Png in C++

开发者 https://www.devze.com 2022-12-08 12:04 出处:网络
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 h开发者_如何学运维aven\'t been defin

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 h开发者_如何学运维aven'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


HBITMAP bmp;
CImage image;
image.Attach(bmp);
image.Save("filename.jpg"); // change extension to save to png


defining min and max as follows:

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif

and putting them BEFORE the gdi plus include worked for me :)

0

精彩评论

暂无评论...
验证码 换一张
取 消