Save CBitmap to File

Published on Monday, September 25, 2006

Source

Save CBitmap to File

It has always astounded me why the CBitmap class never implemented saving to a file. Here's a nice and tidy way:

#include <atlimage.h>

#include <Gdiplusimaging.h>

//…

CBitmap bitmap;

bitmap.CreateBitmap(width, height, 1, 32, rgbData);

CImage image;

image.Attach(bitmap);

image.Save(_T("C: est.bmp"), Gdiplus::ImageFormatBMP);

comments powered by Disqus