About | Buy Stuff | News | Products | Rants | Search | Security | Social
Home » Resources » Rants

MonkeyDraw

Week of Halloween, 2001

Wasting RAM for no good reason.

The initial impression of Windows XP is that it is sluggish, and subsequent impressions are not likely to be different. At the epicentre of this lameness is the lugubrious shell32.dll, a monster of a file already back in 1995 but now in a Godzilla class all its own. Initially tipping the megabyte scale only slightly, this mutant nightmare is now almost eight megabytes on disk - 7.93MB to be more exact. And it's not code that's hidden within either.

It's icons. Icons and other images. Stored in the impressive 16.7 million colour format at sizes heretofore unknown to mankind, such as 96x96, designed no doubt for SGI laptops with 145 inch screens with pixel resolutions somewhere above 10240x7680.

Almost six and one half megabytes of the added bulk of shell32.dll for Windows XP is attributable to these images. But so what, you might say. Look at Apple - they're touting photographic rather than the traditional symbolic or metaphoric icons. If they can do it, why can't Windows?

The answer is that Windows can but doesn't, and that while Apple's photographic icons do use an elaborate palette, Windows does not - and yet still manages to waste acres of disk space and crunch your machine under its overly heavy use of RAM.

How is this possible? Read the title of this article again. Here's a bit of a story. We have to go somewhat back in time...

Icon Essentials
In the old days (read: 1992 or earlier) Windows had a 20 colour palette. Pure yellow, pure blue, pure red, halfway red, halfway blue, etc. and two shades of gray and white and black. This was known as the system palette, but it was also the default palette for icons.

But these icons used the palette system, that is the first part of these icon files (which are really only bitmap files with AND and OR masks thrown in) was the palette with sixteen entries. Every pixel in the icon (bitmap) was an index value, not a colour value (the colours are always saved as 32-bit values, the number of colours was however limited to sixteen).

Which is why we speak of 4-bit palettes, because four bits (half a byte) is enough to carry a colour if all you have is sixteen colours. The palette itself, sixteen colours times four bytes (32 bits) per colour, takes only sixty four (64) bytes. The image itself for a 32x32 icon needs only 32 * 32 * 4 bits or 512 bytes. Add to that the mask and the headers and you have a nice neat 766 bytes on disk.

Wonderfully Microsoft went on using the same colours all the time even though the palette itself was by definition configurable. If you went into the palette and changed the values of the entries you would get completely different colours, and the operating system itself would do graciously, realising a new palette while your application was on screen. Admittedly, earlier versions of Windows did have problems with certain colour combinations if your video card was set to a lower colour resolution, but snags such as this are almost totally a thing of the past today.

Losing Diapers
Then Microsoft promoted itself to the 8-bit or 256 colour palette. The funny thing here is that Microsoft never really understood how its own palette scheme for its own operating system worked. And strangely not many other people do even to this day. So when the brilliant designers in Redmond wanted more and groovier colours than their 16/20 colour palette would give them, they looked to their new improved graphical tools (MsDev) to create new icons with 256 colours instead.

The funny thing here is that these Einsteins normally did not use more than 16 colours, they just used different colours. But as they never really understood what was going on here, and as their own MsDev is totally incapable of dealing with this, the icons were all saved with a 256 colour palette instead.

Quickies
A quick session with a 'real' graphics editor shows how easy it is. MsDev cannot handle it, but a real graphics editor can. You take one of MS's old 256-colour icons, copy it to the clipboard and paste it into the 'real' editor, then check how many colours the 256-colour icon really has. Normally it's only 9 or 10. You then create a 16-colour 4-bit palette for the image, save it, have MsDev load it, and finally paste the image back in.

A multi-kilobyte icon automatically gets back down to 766 bytes for a single 32x32 image or about 1KB with a 16x16 in its pouch. Multiply the disk free space you won back times every icon in every file in your system - if you can find and count them all...

Alea Iacta
But now is when the matter gets really dicey, because now we have the all-new Windows XP or Godzilla Returns With A Vengeance and its nest egg shell32.dll. This file was already the biggest file on NT4 at just over 1MB; now it's 7.93MB - and that's mostly because of the icons, which are now in 16.7 million colours.

Now what applied to the old extravagant 256-colour icons from Redmond applies here as well. The new super heavy icons don't have 16.7 million colours of course - most have significantly less than 256 colours, so these can be reduced in the same way as the old 256-colour icons. And again the savings are great, in fact much greater, for the step from 4 bits to 8 bits is nothing like the step from 8 bits to 32 bits, and Microsoft in its wisdom has now included 96x96 pixel images for most of these icons, and they are of course huge.

Monkey Draw
Brilliant colour sure. It looks good. Photographic icons sure - but XP doesn't have that and still looks like an Infants Paradise. But the punch line here is that none of this - or very little - should have to cost much RAM. All it needs is a bunch of monkeys in Redmond with more IQ than your average turnip who are taught by their superiors how to handle bitmap palettes.

About | Buy Stuff | News | Products | Rants | Search | Security | Social
Copyright © Radsoft. All rights reserved.