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:\\test.bmp"), Gdiplus::ImageFormatBMP);