Valhalla Legends Forums Archive | General Programming | Bitmaps, Icons, and Cursors

AuthorMessageTime
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?
February 9, 2009, 9:08 PM
chyea
Your initial thought was to create your own paint program and not to just go download one of the thousands out there?
February 10, 2009, 3:53 AM
Myndfyr
[quote author=chyea link=topic=17824.msg181604#msg181604 date=1234238006]
Your initial thought was to create your own paint program and not to just go download one of the thousands out there?
[/quote]
Because the one that came with Windows has too many features, no less.

http://www.irfanview.com/
February 10, 2009, 4:34 AM
Barabajagal
Neither of you are of any help whatsoever. Mynd, you should know better than to stray from the topic question...
February 10, 2009, 5:05 AM
Myndfyr
[quote author=Andy link=topic=17824.msg181606#msg181606 date=1234242310]
Neither of you are of any help whatsoever. Mynd, you should know better than to stray from the topic question...
[/quote]
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....
February 11, 2009, 7:14 AM
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:

[code]
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...[/code]
February 11, 2009, 8:31 AM
Myndfyr
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?
February 11, 2009, 5:01 PM
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?
February 11, 2009, 7:15 PM
Barabajagal
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:
[code]    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)[/code]
I get an invalid image which opens exclusively in GIMP and looks terrible.
February 11, 2009, 11:06 PM
Myndfyr
[quote author=Andy link=topic=17824.msg181616#msg181616 date=1234393602]
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:
[code]    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)[/code]
I get an invalid image which opens exclusively in GIMP and looks terrible.
[/quote]

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.
February 12, 2009, 2:15 AM
Barabajagal
So... each ICO image is DIB + 2 * ([Palette] + Image Data)-'s?
February 12, 2009, 4:12 AM

Search