🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #1021

Reading Icon file formats

#1021
From: Robert Nee
Date: Tue, 08 Jan 1991 15:10
35 lines
1879 bytes
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
   
Technical Details
Message-ID: <144@cf_su20.cf_su10.Sbi.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!spool2.mu.edu!uunet!sbi!zeus!cf_su10!cf_su14!nee

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!spool2.mu.edu!uunet!sbi!zeus!cf_su10!cf_su14!nee
From: nee@cf_su14.Salomon.Com (Robert Nee)
Newsgroups: comp.windows.ms.programmer
Subject: Reading Icon file formats
Message-ID: <144@cf_su20.cf_su10.Sbi.COM>
Date: 8 Jan 91 15:10:33 GMT
Sender: news@cf_su10.Sbi.COM
Reply-To: nee@cf_su14.Salomon.Com (Robert Nee)
Organization: Salomon Brothers, NY
Lines: 35