• Welcome to Valhalla Legends Archive.
 

Bitmaps, Icons, and Cursors

Started by Barabajagal, February 09, 2009, 03:08 PM

Previous topic - Next topic

Barabajagal

Since Windows 7 has Vista's overfeatured and shitty Paint version, I've been working on my own. In the process, I've needed to create some cursors, which has lead me to the .cur and .ico format. In the course of reading icon data, I've noticed something quite strange, which is that the icon data stores a width/height which appears to be correct, but the bitmap data stores a (redundant) width/height in which the height is twice what it should be. Has anyone else run into this, or know what it means?

bulletproof tiger

Your initial thought was to create your own paint program and not to just go download one of the thousands out there?

MyndFyre

Quote from: chyea on February 09, 2009, 09:53 PM
Your initial thought was to create your own paint program and not to just go download one of the thousands out there?
Because the one that came with Windows has too many features, no less.

http://www.irfanview.com/
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Barabajagal

#3
Neither of you are of any help whatsoever. Mynd, you should know better than to stray from the topic question...

MyndFyre

Quote from: Andy on February 09, 2009, 11:05 PM
Neither of you are of any help whatsoever. Mynd, you should know better than to stray from the topic question...
Do you have a link to the format spec that you're using to develop this with?  Maybe a hex-formatted part of the file you're working on....
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Barabajagal

The format is listed on Wikipedia (ICO wraps around BMP with DIB header). I've used multiple ICO files (from online, from personal creations in Visual C++ 6 and GIMP, and from Windows itself), but as an example, I'll use a PHP script icon from PHP.net:


ICO Header:
00 00 01 00 0C 00

ICO Directories (12 of them):
30 30 10 00 01 00 04 00 68 06 00 00 C6 00 00 00
20 20 10 00 01 00 04 00 E8 02 00 00 2E 07 00 00
18 18 10 00 01 00 04 00 E8 01 00 00 16 0A 00 00
10 10 10 00 01 00 04 00 28 01 00 00 FE 0B 00 00

30 30 00 00 01 00 08 00 A8 0E 00 00 26 0D 00 00
20 20 00 00 01 00 08 00 A8 08 00 00 CE 1B 00 00
18 18 00 00 01 00 08 00 C8 06 00 00 76 24 00 00
10 10 00 00 01 00 08 00 68 05 00 00 3E 2B 00 00

30 30 00 00 01 00 20 00 A8 25 00 00 A6 30 00 00
20 20 00 00 01 00 20 00 A8 10 00 00 4E 56 00 00
18 18 00 00 01 00 20 00 88 09 00 00 F6 66 00 00
10 10 00 00 01 00 20 00 68 04 00 00 7E 70 00 00

DIB Header for ICO #1:
28 00 00 00
30 00 00 00 <<Correct Width
60 00 00 00 << Doubled Height
etc...

MyndFyre

Aren't .ico bitmaps stored as two bitmaps - the AND and the XOR versions?  Is it possible that you're seeing the double height because the single DIB section represents both?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Ringo

Yep, i'm pretty sure what MyndFyre said is the case.
If you have a 2 bitmaps, but the ico format is only giving you the offset and size of 1, as well as the bitmap header saying the image is double the size, then it would be safe to assume both images are next to one another.
Andy, why didn't you spend a min or two, to parse an ico file, save the bitmap(s) and check them out?

Barabajagal

#8
I was in the process of doing so when I ran into the double height thing...

The problem is that the parsed BMP data in the ICOs don't have a header, and when I try to add a simple one like so:
    cFile.InsertByte &H42
    cFile.InsertByte &H4D
    cFile.InsertDWORD 14 + Len(ImgData(hsIcons.Value))
    cFile.InsertWORD 0
    cFile.InsertWORD 0
    cFile.InsertDWORD 14 + 40 + PalSize
    cFile.InsertString ImgData(hsIcons.Value)

I get an invalid image which opens exclusively in GIMP and looks terrible.

MyndFyre

Quote from: Andy on February 11, 2009, 05:06 PM
I was in the process of doing so when I ran into the double height thing...

The problem is that the parsed BMP data in the ICOs don't have a header, and when I try to add a simple one like so:
    cFile.InsertByte &H42
    cFile.InsertByte &H4D
    cFile.InsertDWORD 14 + Len(ImgData(hsIcons.Value))
    cFile.InsertWORD 0
    cFile.InsertWORD 0
    cFile.InsertDWORD 14 + 40 + PalSize
    cFile.InsertString ImgData(hsIcons.Value)

I get an invalid image which opens exclusively in GIMP and looks terrible.

They're not going to look correct - you need to use and combine the bitmap data in both bitmaps in order to make a bitmap that properly represents the original icon.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Barabajagal

#10
So... each ICO image is DIB + 2 * ([Palette] + Image Data)-'s?