Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!paperboy!hsdndev!dartvax!eleazar.dartmouth.edu!ari From: ari@eleazar.dartmouth.edu (Ari Halberstadt) Newsgroups: comp.sys.mac.programmer Subject: Re: On writing an LDEF to draw icons: store icon data or handle? Summary: Store icon IDs Message-ID: <1991Jun2.184919.18715@dartvax.dartmouth.edu> Date: 2 Jun 91 18:49:19 GMT References: <01G6IKL90CBQ8WWD4Y@WVNVMS.WVNET.EDU> Sender: news@dartvax.dartmouth.edu (The News Manager) Organization: Dartmouth College, Hanover, NH Lines: 34 In article <01G6IKL90CBQ8WWD4Y@WVNVMS.WVNET.EDU> you write: >Subject: On writing an LDEF to draw icons: store icon data or handle? >Newsgroups: comp.sys.mac.programmer >Reply-To: un020070@vaxa.wvnet.edu > >I'm writing a list definition (LDEF) to draw icons from the list manager. >I can think of two ways to store the data: > >1. Store the actual data (128 bytes, I think) of the icon as the cell > data. This is fairly simple. If your icon is 128 bytes, then you can have a maximum of 32768 (or is it 32767) divided by the size of an icon, which gives us 256 (no, 255) icons in the list. This is a very compact way to store them: no wasted space, but 255 is a very small number. And if you're also storing an icon mask, then each icon is twice as big, giving you even less icons in the list. >2. Store a *handle* to the icon in the cell data; this will make the > cell data only a longword long. The icon itself will be somewhere > else in memory. > This way you can have 32767/4 = 8191 icons. But you'll waste more space: 8 bytes for each handle header, plus 4 bytes for each master pointer, or a maximum "wasted" space of 12 * 8191 = 98292. This is a lot. A better solution is to store the icon's ID, or only 2 bytes per icon, giving you a maximum of 16383 icons with no wasted space. When you need the icon, simply call GetIcon. If the icon has been purged, then it will be read in, if it's not purged it will be returned immediately.