[comp.windows.ms.programmer] Reading Icon file formats

nee@cf_su14.Salomon.Com (Robert Nee) (01/08/91)

I have another question for the experts (davidds are you listening?)
I am trying to read icon files and create icons using CreateIcon.
The icon that gets created though is not exactly correct.  It has 
some resemblance to the correct icon but some colors are shifted
around and stuff.

The procedure I use is as follows:

   1) Read the resource file header
   2) After checking that it is an icon, read the icon file 
	   header.
   3) Read the Bitmap header at the specified offset.

Inspection using CVW shows that this information in the previous steps 
is being read correctly.  Now for the parts I'm not sure about.

   4) For a 16 color icon read and DISCARD the color table.
   5) Read the XOR (color) bitmap the length of which should be 
      Length * Width * BitsPerPixel / 8
   6) Read the AND (mono) bitmap (Length * Width / 8) Bytes long.

OK so far?  should I be discarding that color table?  Is it in fact
a color table or something else?

    7) Call CreateIcon to get a handle to an Icon
       hIcon = CreateIcon (hInst, Width, Height, 1, BitsPerPixel, MonoBits,
                              ColorBits);

I added up the sizes of all data structures and arrived at the proper
total size of 766 (for a single-icon icon file).  I have a feeling there
is something wrong with the way I read or pass the Bitmaps but I can't
figure it out.  Any help is appreciated.  Thanks.

Robert Nee
   

nee@cf_su20.sbi.Com (Robert Nee) (01/24/91)

I am sorry.  My REAL mail address for anyone who tried
to reply to my original post and got bounced is
<nee@cf_su20.sbi.com>.

Robert F. Nee