How to save CBitmap to file
-
Hello, I need to make a *.bmp file out of my CBitmap file. I do not know about bitmaps so much and i cannot make conversions between different types. Can someone help me? Thanks in advance
You can't save the CBitmap as it is into a file. You will have to convert the CBitmap which is a DDB into a DIB. The bytes for the pixels in the CBitmap are device dependent, only the graphics driver knows how to interpret the pixel values(RGB) corresponding to what a byte or triplet denote. So the first step would be to convert to a DIB. To do that, you will have to use the GetBitmap(...) method on the CBitmap and then get the DDB bitmap's dimensions. You should then create a DIB, this is normally done using CreateDIBSection(...), you should fill in the BITMAPINFOHEADER and then be done with creating the BMP with the right color depth. I would then BitBlt between a device context having a DDB into another memory device context having the DIB and the underlying graphics driver or DI would convert the DDB(your CBitmap)to DIB. You can now save the DIB to a file. Well the above are the fundamental set of operations to do it. There are already built-up classes here in codeproject. Have a look at this article "CDibData", linking to which you can get what you want. http://www.codeproject.com/bitmap/jscdibdata.asp[^] Microsoft - MVP
-
Hello, I need to make a *.bmp file out of my CBitmap file. I do not know about bitmaps so much and i cannot make conversions between different types. Can someone help me? Thanks in advance
Articles at CP (Bitmaps & Palettes): CxImage, CDibData, "Saving a Drawing to a Bitmap File". There are probably others. INTP Every thing is relative...