8 bit bmp
-
Hey frnds Can any one tell me how to create 8 bit bitmap thx in advance
Born To Code
-
Hey frnds Can any one tell me how to create 8 bit bitmap thx in advance
Born To Code
You've asked this before....what part of the process is giving you trouble? Do you want a device-dependent bitmap, a device-independent bitmap, ...?? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
You've asked this before....what part of the process is giving you trouble? Do you want a device-dependent bitmap, a device-independent bitmap, ...?? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
Can u plz explain how to draw 8 bit bitmap using palette. The bitmap should be of 256 color, thnaks
-
Can u plz explain how to draw 8 bit bitmap using palette. The bitmap should be of 256 color, thnaks
I still don't know what type of bitmap you're using. You draw 8-bit bitmaps the same as any bitmaps. You can use GetDeviceCaps(RASTERCAPS) to check if the destination DC is a palette device. If it is, select your palette into it, call RealizePalette() (usually), and draw the bitmap. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
I still don't know what type of bitmap you're using. You draw 8-bit bitmaps the same as any bitmaps. You can use GetDeviceCaps(RASTERCAPS) to check if the destination DC is a palette device. If it is, select your palette into it, call RealizePalette() (usually), and draw the bitmap. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
thank u Sir, but tell me how to know whether the destination DC is a palette device or not? if not then how to set.
-
thank u Sir, but tell me how to know whether the destination DC is a palette device or not? if not then how to set.
rahul.shendurnikar wrote:
how to know whether the destination DC is a palette device or not?
if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
{
// Is palette device
}How to set it depends on the device. For a monitor, it's based on the video mode. For a printer device it's based on the bitmap format selected into the dc. etc... Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
rahul.shendurnikar wrote:
how to know whether the destination DC is a palette device or not?
if (GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE)
{
// Is palette device
}How to set it depends on the device. For a monitor, it's based on the video mode. For a printer device it's based on the bitmap format selected into the dc. etc... Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
:wtf:hey my destination DC is not a palette device. destination DC is my Monitor. Can u plz send me code snipet which create 8 bit bitmap usning palette. the palette aaray should be..... static int ARGB[256][3] = { {0,0,0}, //0 {48,0,0}, //1 {48,48,48}, //2 {0,16,16}, //3 {32,32,32}, //4 {16,16,16}, //5 {0,48,0}, //6 {48,48,0}, //7 {0,48,48}, //8 {0,16,16}, //9 {80,80,80}, //10 {96,96,96}, //11 {96,96,96}, //12 {112,112,112}, //13 {128,128,128}, //14 {144,144,144}, //15 {160,160,160}, //16 {160,160,160}, //17 {176,176,176}, //18 {192,192,192}, //19 {208,208,208}, //20 {208,208,208}, //21 {208,208,208}, //22 {224,224,224}, //23 {224,224,224}, //24 {224,224,224}, //25 {240,240,240}, //26 {96,48,48}, //27 {96,48,0}, //28 {96,0,0}, //29 {96,0,96}, //30 {96,48,96}, //31 {160,0,96}, //32 {160,48,96}, //33 {160,0,32}, //34 {160,48,48}, //35 {160,48,0}, //36 {160,0,0}, //37 {160,96,96}, //38 {160,96,48}, //39 {160,96,0}, //40 {208,0,96}, //41 {208,48,96}, //42 {208,96,96}, //43 {208,96,0}, //44 {208,96,48}, //45 {208,48,48}, //46 {208,48,0}, //47 {208,0,0}, //48 {240,96,96}, //49 {240,0,112}, //50 {240,48,96}, //51 {240,0,96}, //52 {240,96,48}, //53 {240,96,0}, //54 {240,16,32}, //55 {240,80,80}, //56 {240,0,0}, //57 {240,128,128}, //58 {240,160,160}, //59 {240,160,160}, //60 {240,160,208}, //61 {240,96,208}, //62 {240,96,240}, //63 {224,16,208}, //64 {224,16,208}, //65 {240,0,176}, //66 {240,0,160}, //67 {240,48,160}, //68 {240,96,160}, //69 {208,0,144}, //70 {208,0,160}, //71 {208,48,160}, //72 {208,96,160}, //73 {240,0,208}, //74 {208,96,208}, //75 {208,0,208}, //76 {208,96,208}, //77 {208,48,208}, //78 {240,0,240}, //79 {240,48,240}, //80 {240,160,240}, //81 {240,208,240}, //82 {208,160,96}, //83 {208,160,48}, //84 {208,160,0}, //85 {208,160,48}, //86 {208,160,160}, //87 {240,208,160}, //88 {240,208,160}, //89 {240,208,192}, //90 {240,208,208}, //91 {208,160,208}, //92 {176,160,144}, //93 {208,208,160}, //94 {208,208,160}, //95 {208,208,160}, //96 {240,240,208}, //97 {240,240,208}, //98 {96,96,0}, //99 {96,96,48}, //100 {0,96,0}, //101 {48,96,0}, //102 {0,96,48}, //103 {48,96,48}, //104 {0,128,0}, //105 {96,160,48}, //106 {96,160,96}, //107 {48,160,96}, //108 {0,160,96}, //109 {0,160,48}, //110 {48,160,48}, //111 {48,160,0},
-
:wtf:hey my destination DC is not a palette device. destination DC is my Monitor. Can u plz send me code snipet which create 8 bit bitmap usning palette. the palette aaray should be..... static int ARGB[256][3] = { {0,0,0}, //0 {48,0,0}, //1 {48,48,48}, //2 {0,16,16}, //3 {32,32,32}, //4 {16,16,16}, //5 {0,48,0}, //6 {48,48,0}, //7 {0,48,48}, //8 {0,16,16}, //9 {80,80,80}, //10 {96,96,96}, //11 {96,96,96}, //12 {112,112,112}, //13 {128,128,128}, //14 {144,144,144}, //15 {160,160,160}, //16 {160,160,160}, //17 {176,176,176}, //18 {192,192,192}, //19 {208,208,208}, //20 {208,208,208}, //21 {208,208,208}, //22 {224,224,224}, //23 {224,224,224}, //24 {224,224,224}, //25 {240,240,240}, //26 {96,48,48}, //27 {96,48,0}, //28 {96,0,0}, //29 {96,0,96}, //30 {96,48,96}, //31 {160,0,96}, //32 {160,48,96}, //33 {160,0,32}, //34 {160,48,48}, //35 {160,48,0}, //36 {160,0,0}, //37 {160,96,96}, //38 {160,96,48}, //39 {160,96,0}, //40 {208,0,96}, //41 {208,48,96}, //42 {208,96,96}, //43 {208,96,0}, //44 {208,96,48}, //45 {208,48,48}, //46 {208,48,0}, //47 {208,0,0}, //48 {240,96,96}, //49 {240,0,112}, //50 {240,48,96}, //51 {240,0,96}, //52 {240,96,48}, //53 {240,96,0}, //54 {240,16,32}, //55 {240,80,80}, //56 {240,0,0}, //57 {240,128,128}, //58 {240,160,160}, //59 {240,160,160}, //60 {240,160,208}, //61 {240,96,208}, //62 {240,96,240}, //63 {224,16,208}, //64 {224,16,208}, //65 {240,0,176}, //66 {240,0,160}, //67 {240,48,160}, //68 {240,96,160}, //69 {208,0,144}, //70 {208,0,160}, //71 {208,48,160}, //72 {208,96,160}, //73 {240,0,208}, //74 {208,96,208}, //75 {208,0,208}, //76 {208,96,208}, //77 {208,48,208}, //78 {240,0,240}, //79 {240,48,240}, //80 {240,160,240}, //81 {240,208,240}, //82 {208,160,96}, //83 {208,160,48}, //84 {208,160,0}, //85 {208,160,48}, //86 {208,160,160}, //87 {240,208,160}, //88 {240,208,160}, //89 {240,208,192}, //90 {240,208,208}, //91 {208,160,208}, //92 {176,160,144}, //93 {208,208,160}, //94 {208,208,160}, //95 {208,208,160}, //96 {240,240,208}, //97 {240,240,208}, //98 {96,96,0}, //99 {96,96,48}, //100 {0,96,0}, //101 {48,96,0}, //102 {0,96,48}, //103 {48,96,48}, //104 {0,128,0}, //105 {96,160,48}, //106 {96,160,96}, //107 {48,160,96}, //108 {0,160,96}, //109 {0,160,48}, //110 {48,160,48}, //111 {48,160,0},
Given your palette, here's one way:
LONG lImageWidth = 320;
LONG lImageHeight = 240;
WORD wBitsPerPixel = 8;LONG lBytesPerRow = (((lImageWidth * (long)wBitsPerPixel + 31L) & (~31L)) / 8L);
BITMAPINFO *pbmi = (BITMAPINFO *)new BYTE[sizeof(BITMAPINFO) + sizeof(RGBQUAD) * 255];
memset(pbmi, 0, sizeof(BITMAPINFO));
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = lImageWidth;
pbmi->bmiHeader.biHeight = lImageHeight;
pbmi->bmiHeader.biPlanes = 1;
pbmi->bmiHeader.biBitCount = wBitsPerPixel;
pbmi->bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biSizeImage = lBytesPerRow * lImageHeight;
//pbmi->bmiHeader.biXPelsPerMeter = 0;
//pbmi->bmiHeader.biYPelsPerMeter = 0;
//pbmi->bmiHeader.biClrUsed = 0;
//pbmi->bmiHeader.biClrImportant = 0;for (int i = 0; i < 256; i++)
{
pbmi->bmiColors[i].rgbBlue = (BYTE)ARGB[i][2];
pbmi->bmiColors[i].rgbGreen = (BYTE)ARGB[i][1];
pbmi->bmiColors[i].rgbRed = (BYTE)ARGB[i][0];
pbmi->bmiColors[i].rgbReserved = 0;
}BYTE* pBitmapBits;
HDC hdc = ::GetDC(0);
HBITMAP hBitmap = ::CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, &pBitmapBits, NULL, 0);
::ReleaseDC(0, hdc);if (hBitmap)
{
// Initialize the bitmap bits to all black (index 0 in color table)
memset(pBitmapBits, 0, pbmi->bmiHeader.biSizeImage);
...
// do stuff with the new HBITMAP
...
::DeleteObject(hBitmap);
delete[] (BYTE *)pbmi;
}"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Given your palette, here's one way:
LONG lImageWidth = 320;
LONG lImageHeight = 240;
WORD wBitsPerPixel = 8;LONG lBytesPerRow = (((lImageWidth * (long)wBitsPerPixel + 31L) & (~31L)) / 8L);
BITMAPINFO *pbmi = (BITMAPINFO *)new BYTE[sizeof(BITMAPINFO) + sizeof(RGBQUAD) * 255];
memset(pbmi, 0, sizeof(BITMAPINFO));
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = lImageWidth;
pbmi->bmiHeader.biHeight = lImageHeight;
pbmi->bmiHeader.biPlanes = 1;
pbmi->bmiHeader.biBitCount = wBitsPerPixel;
pbmi->bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biSizeImage = lBytesPerRow * lImageHeight;
//pbmi->bmiHeader.biXPelsPerMeter = 0;
//pbmi->bmiHeader.biYPelsPerMeter = 0;
//pbmi->bmiHeader.biClrUsed = 0;
//pbmi->bmiHeader.biClrImportant = 0;for (int i = 0; i < 256; i++)
{
pbmi->bmiColors[i].rgbBlue = (BYTE)ARGB[i][2];
pbmi->bmiColors[i].rgbGreen = (BYTE)ARGB[i][1];
pbmi->bmiColors[i].rgbRed = (BYTE)ARGB[i][0];
pbmi->bmiColors[i].rgbReserved = 0;
}BYTE* pBitmapBits;
HDC hdc = ::GetDC(0);
HBITMAP hBitmap = ::CreateDIBSection(hdc, pbmi, DIB_RGB_COLORS, &pBitmapBits, NULL, 0);
::ReleaseDC(0, hdc);if (hBitmap)
{
// Initialize the bitmap bits to all black (index 0 in color table)
memset(pBitmapBits, 0, pbmi->bmiHeader.biSizeImage);
...
// do stuff with the new HBITMAP
...
::DeleteObject(hBitmap);
delete[] (BYTE *)pbmi;
}"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
Thank u so much...
Born To Code