直接上代码
// Colour table.
const RGBQUAD tab[2] = {
{0,0,0,0}, {255, 255, 255, 0}
};
_TCHAR file[] = TEXT("D:\\image\\frist.bmp");
CImage oBmp;
HRESULT hRes = oBmp.Load(file);
if (S_OK == hRes) {
CImage oOneBit; // Construct the CImage
oOneBit.Create(oBmp.GetWidth(), oBmp.GetHeight(), 1); // Create and attach a bitmap
oOneBit.SetColorTable(0, 2, tab); // Set the colour table
oBmp.BitBlt(oOneBit.GetDC(), 0, 0, SRCCOPY); // Copy the bitmap
oOneBit.ReleaseDC(); // Done with DC
oOneBit.Save(L"D:\\image\\frist_1.bmp");
}