So, I want to save an HBITMAP to different image file formats like BMP,PNG and JPEG. I believe that the most simple way to do it is by using GDI+. So here is what I came up with.

Gdiplus::Bitmap bmp(hbmpImage,(HPALETTE)0);
CLSID pngClsid;
GetEncoderClsid(L"image/png", &pngClsid);
bmp.Save(L"D:\image.png",&pngClsid,NULL);

The problem is that it doesn't work, and I get a bunch of errors "error LNK2019: unresolved external symbol". I got GetEncoderClsid() function from MSDN, but I don't believe that this is the problem. Probably it's something else something I'm missing or something I don't know.
I tried to do it the old way but I got lost in all those file headers and info headers, and I can't find any understandable info about how to use them.

I would really appreciate any help.

Your error message indicates that you're not linking your executable against whatever library contains the compiled implementation code for GetEncoderClsid(). Go back to the documentation on MSDN, there's probably something there that tells you what library you need to specify in your Build set-up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.