I'm working with a CBitmap object using a CDC. When I'm finished with it I want to save it to a file. I have seen something about a process with that code LINK:
CFile file;
if(file.Open(szFileName, CFile::modeCreate | CFile::modeWrite))
{
file.Write(&bh, sizeof(BITMAPFILEHEADER));
file.Write(&(bi.bmiHeader), sizeof(BITMAPINFOHEADER));
file.Write(lpBitmapBits, 3 * nWidth * nHeight);
file.Close();
}
My doubt is about BITMAPFILEHEADER and BITMAPINFOHEADER. How can I fill them with a given CBitmap or CDC?
You could try this:
CImage image;
image.Attach(CDCvar.GetCurrentBitmap());
image.Save(_T(".\\test.bmp"), Gdiplus::ImageFormatBMP);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With