Convert BITMAP to PNG using IImage interface on Windows Mobile
I have a link to a BITMAP structure (HBITMAP) in a Windows Mobile application - I would like to save the bitmap as a PNG file using IImage if possible. (In this situation, there is no BMP file, BITMAP is only in memory).
It looks like I could use IImagingFactory's IImagingFactory :: CreateImageEncoderToFile method to save the file, but I think I needed to get the BITMAP converted to "IImage" format first.
Any ideas on how to do this with your own code?
0
a source to share
1 answer
Use CreateImageFromStream to read BITMAP into your data, which gives you IImage.
Edit:
I've done a little more research on this. There are several ways, but I think the easiest is:
- create a DIBSECTION and include its bitmap.
- Create a BitmapData instance pointing to the DIBSECTION for the image data.
- Call CreateBitmapFromBuffer to create the IBitmapImage interface
- Click IBitmapImage (which is IImage) through your encoder.
+1
a source to share