🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to display an icon from a .ICO file -- not a resource ?

#1599
From: Mike Sullivan
Date: Mon, 11 Mar 1991 13:29
32 lines
1926 bytes
heath@ncrcae.Columbia.NCR.COM (Robert Heath) writes:

>How does one read in and display the contents of a .ICO file within
>a Win app ? (I realize the normal way is to compile in a .ICO as a resource via 
>"rc".)   I want to be able to have  the user specify which .ICO file 
>to display at runtime.  I can't seem to find out how to do this in
>the literature.

>	Robert Heath

Back when _I_ was a windows weenie I wrote a routine called IconLoad
which took a filename.  It opened the file, read a header ( which is 
defined in the literature ) determined whether it really was an icon
and what size icon, and then read rest of the file into bitmaps.

I also wrote IconDraw and IconMove.  The other advantage that doing 
own routines gave me is that I was able to colorize them.  DrawIcon
always drew them in B&W for some reason.  (IconMove allowed me to 
drag an Icon around on the screen.  Performance was quite reasonable.

Anyway the secret to drawing the Icon is to first draw the mask in the
desired background color using BitBlt with SRCAND.  

Then draw the bits using the desired foreground color using BitBlt 
and SRCINVERT.

-- 
  ________________________
 /                    __  \  | Michael J. Sullivan    |ec.lec.tic adj Choosing
| \  \  /  /\  |\ |  /  `  | | Wang Laboratories Inc. |or consisting of what 
|  \/ \/  /--\ | \|  \__T  | | mike@WANG.COM	      |appears to be the best 
 \________________________/  | 			      |from diverse sources.
Technical Details
Message-ID: <b24isn.4vw@wang.com>
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!decwrl!uunet!wang!mike
References: <7131@ncrcae.Columbia.NCR.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!rutgers!usc!elroy.jpl.nasa.gov!decwrl!uunet!wang!mike
From: mike@wang.com (Mike Sullivan)
Newsgroups: comp.windows.ms.programmer
Subject: Re: How to display an icon from a .ICO file -- not a resource ?
Keywords: .ICO icon
Message-ID: <b24isn.4vw@wang.com>
Date: 11 Mar 91 13:29:11 GMT
References: <7131@ncrcae.Columbia.NCR.COM>
Organization: Wang Labs, Lowell MA, USA
Lines: 32