C++ method to save images in the CBitmap class to a file
- 2020-04-02 03:09:25
- OfStack
This article illustrates how C++ saves images from the CBitmap class to a file. Share with you for your reference. The specific implementation method is as follows:
Using the following code, you can save the image in the CBitmap class to an image file. Supported formats: BMP, JPG, GIF, and PNG.
void SaveBitmap(CString strFilePath, CBitmap Bitmap)
{
if ( Bitmap.m_hObject )
{
CImage imgTemp;
//CImage is a class in MFC.
imgTemp.Attach(Bitmap.operator HBITMAP());
imgTemp.Save(strFilePath);
}
}
Note that the file path name strFilePath must contain a suffix, one of BMP, JPG, GIF, or PNG.
Hope that the article described in the C++ programming to help you.