Converting from HBITMAP to Jpeg or Png in C++
Asked Answered
B

2

8

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

Bermuda answered 7/10, 2009 at 16:23 Comment(0)
P
11
HBITMAP bmp;
CImage image;
image.Attach(bmp);
image.Save("filename.jpg"); // change extension to save to png
Pinnatifid answered 11/11, 2009 at 13:3 Comment(0)
C
-1

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

Constantina answered 7/10, 2009 at 16:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.