
CBitmap: Want to display RGB bitmap, but can only adress G and B
Hello Bernd;
I believe the problem is the current palette (default palette) is 16 color(4
bit).
Also special consideration is given to 24bit color as each pixel contains
its palette, so to speak. When you have an image that is 24 bit and trying
to display it in 256 color(8bit) you have to do special rendering.
But there is some point of confusion for me, I thought that there was an
issue of apps no-longer using palettes on the newer video drivers for
Windows 98/2000.
Or maybe it was just AnimatePalette no longer works??
Try creating and selecting a palette. Creating a 256 color palette is not
hard. You could probably find a msdn example.
Hope this helps.
Richard Jones
Quote:
>Hi all,
>I am trying to display a bitmap to the current device context by first
>creating a BITMAP structure, then using
>CBitmap::CreateBitmapIndirect, then
>CDC::CreateCompatibleDC, then
>CDC::SelectObject (CBitmap) and finally
>CDC::BitBlt
>This works fine so far, but I have a problem with initializing my BITMAP
>structure. I want to generate an RGB bitmap, and naive as I am I thought
>this would work by setting the variable bmBitPixel of the BITMAP structure
>to 24 (24 Bits per Pixel), BUT this does not work. I was playing around
with
>the variables bmBitPixel, bmPlanes and bmWidthBytes a lot, but every time I
>only get one (ONE !!!) pixel displayed. The only combination that works is
>to set bmPlanes to 1, bmBitPixel to 16 and to assign an array to bmBits
>where two bytes represent the color of one pixel. BUT two bytes are not
>enough to dsiplay RGB. I can generate blue bitmaps or yellow bitmaps that
>way, but it seems to be impossible to create a RED bitmap !!!
>Has anyone an idea of how I can display a REAL RGB bitmap (without using
>SetPixel or SETPixelV which is much to slow) ???
>Thanks in advance
>Bernd