I am writing a signature capture control in C++ for Windows Mobile and Windows. On the Windows side I have many different ways to save a CBitmap to a PNG file (GDI+, CImage, etc.). The problem I’ve encountered is CImage::Save() isn’t implemented on Windows Mobile. The good parts of GDI+ are also not implemented on Windows Mobile (specifically, Gdiplus::Bitmap).
I’ve found the IImagingFactory API and had success loading a PNG with this library, but I cannot figure out how to save a CBitmap to a PNG file on Windows Mobile. Does anyone have any ideas to save a HBITMAP or CBitmap to a PNG file?
If it makes any difference, the CBitmap was created to match the size of the control and it has 1BPP since the signature image is black and white and needs to be transferred over the network.
I’ve learned IImagingFactory encoder was failing because my CBitmap is a DDB rather than DIB. I used CreateDIBSection to create the bitmap instead of CBitmap.Create() and was able to encode the CBitmap to PNG using IImagingFactory.
Hope this helps the next person who goes down this path (only tested with 1BPP):
Tying it all together: