From: c2s4027@tamsun.tamu.edu (Cedric Sims)
Newsgroups: comp.os.ms-windows.programmer.misc
Subject: Re: Displaying 256-Colors DIB Help Needed
Date: 4 Jan 1993 08:13:03 -0600
Organization: Texas A&M University, College Station, TX
NNTP-Posting-Host: tamsun.tamu.edu

In article <1993Jan2.095806.823@ualr.edu> pacheco@acs.harding.edu writes:
>If anyone can help with this problem I would be very appreciative.
>
>I have created a 256 color bitmap in my resource file.  I am trying to
>display the bitmap on the screen.  I am using the GetDIBits function
>with the wUsage parameter set to DIB_RGB_COLORS to retrieve the color
>information for the bitmap in order to create a logical palette (is this
>the correct procedure ... ?).  However, even though the resulting
>bmiColors[] array contains 256 elements, all of the entries have RGB
>values of (0,0,0) except for the 20 entries reserved by the system.
>
>I have loaded my .EXE with a resource editor and viewed the bitmap to
>confirm that it is 256 color and indeed it is.
>
>Any help?  This is the first time I have worked with 256 color bitmaps
>and I would appreciate any information anyone has to offer.
>
>Thanks in advance ...
>
>Ron
>
>------------------------------------------------------------------------
> Ron Pacheco \pa-chek'-oh\  |  HARDING UNIVERSITY     Searcy, Arkansas
> pacheco@harding.edu    ;)  |  Dept. of Mathematics & Computer Science
>------------------------------------------------------------------------

I have the same problem.  I have a 256 bitmap in a resource file. The
palette contains 20 system default colors and the rest are RGB(0,0,0).
What's the problem?  I am using BC++3.1. The original BMP file is
included in my resource file using the following line...

#define IDB_BACKGROUND xx

IDB_BACKGROUND BITMAP "<path info>\filename.bmp"

I use MAKEINTRESOURCE and LoadBitmap to get a handle. According to the
C700 Reference and the BC++ Help file, the bitmap format of a resource is
the same as that in a file with the BITMAPFILEHEADER removed. 

So... (someone correct me if I'm wrong) the bitmap should be composed of...

   BITMAPINFOHEADER  +  the bitmap bits

To get to the palette I am using a pointer as such...

   LPBITMAPINFOHEADER lpbi;

   lpRGB = (LPRGBQUAD) ((LPSTR)lpbi + (UINT)lpbi->bisize);

To extract the palette, I'm using the following...

   for (i=0; i < uNumColors; i++)
   {
      pPal->palPalEntry[i].peRed   = lpRGB[i].rgbRed;
      pPal->palPalEntry[i].peGreen = lpRGB[i].rgbGreen;
      pPal->palPalEntry[i].peBlue  = lpRGB[i].rgbBlue;
      pPal->palPalEntry[i].peFlags = (BYTE) 0;
   }

Finally I create the palette using...

   hPalette = CreatePalette (pPal);

When I use my debugger to what the palette being transfered into
the LOGPALETTE struct, the first 20 are the system palette defaults
and the remaining 236 colors are RGB(0,0,0). Any suggestions? Should
I store my bitmap in a RC_DATA type instead of RC_BITMAP so that I
get a perfect copy of the BMP file in my resource?  The only examples
I've seen for 256 BMP's are opening DIB files, NOT DIB resources. I
would be very greatful for any suggestions.

Thanks,
Cedrico.
-------------------------------------------------------------------
 Cedric J. Sims                               Texas A&M University
                                         Computing Services Center
 cedrics@tamu.edu                          (SELL)  Room 216 Teague
 +1 409 862 4104                    College Station, Tx 77843-3142
-------------------------------------------------------------------
Newsgroups: comp.os.ms-windows.programmer.misc