K
KQWong
Guest
Hi, Im using GDI+ to convert the bitmap pixel format from 24bit to 1 bit by using below code:
GdiplusStartupInput sti; // Initialize Gdiplus
ULONG_PTR gpToken;
int n = sizeof sti;
GdiplusStartup(&gpToken, &sti, NULL);
Bitmap* myBitmap = new Bitmap(Bitmap Path Name); // Load the bitmap from the path name
PixelFormat pxf = myBitmap->GetPixelFormat();
Gdiplus::ColorPalette* pal = (Gdiplus::ColorPalette*)malloc(sizeof(Gdiplus::ColorPalette) + 2 * sizeof(Gdiplus::ARGB));
pal->Count = 2;
pal->Flags = 0;
Gdiplus::Bitmap::InitializePalette(pal, Gdiplus:aletteTypeFixedBW, 2, FALSE, NULL);
// Convert the bitmap pixel format to 1 bit monochrome (PixelFormat1bppIndexed)
myBitmap->ConvertFormat(PixelFormat1bppIndexed, Gdiplus:itherTypeErrorDiffusion, Gdiplus:aletteTypeFixedBW, pal, 0);
pxf = myBitmap->GetPixelFormat();
After convert the pixel format successfully, I'm facing the problem to save this altered bitmap image, can anyone please help me on this problem T.T
Thanks!
Continue reading...
GdiplusStartupInput sti; // Initialize Gdiplus
ULONG_PTR gpToken;
int n = sizeof sti;
GdiplusStartup(&gpToken, &sti, NULL);
Bitmap* myBitmap = new Bitmap(Bitmap Path Name); // Load the bitmap from the path name
PixelFormat pxf = myBitmap->GetPixelFormat();
Gdiplus::ColorPalette* pal = (Gdiplus::ColorPalette*)malloc(sizeof(Gdiplus::ColorPalette) + 2 * sizeof(Gdiplus::ARGB));
pal->Count = 2;
pal->Flags = 0;
Gdiplus::Bitmap::InitializePalette(pal, Gdiplus:aletteTypeFixedBW, 2, FALSE, NULL);
// Convert the bitmap pixel format to 1 bit monochrome (PixelFormat1bppIndexed)
myBitmap->ConvertFormat(PixelFormat1bppIndexed, Gdiplus:itherTypeErrorDiffusion, Gdiplus:aletteTypeFixedBW, pal, 0);
pxf = myBitmap->GetPixelFormat();
After convert the pixel format successfully, I'm facing the problem to save this altered bitmap image, can anyone please help me on this problem T.T
Thanks!
Continue reading...