I'm doing some work where I'm programmatically downloading icons from sites specified in an OpenSearch document and I need to extract the first image (for now) if it is in ICO format. I'm able to read the ICO file header with no problems and slice out the first image file. However, after reading the Wikipedia entry explaining the file format I've discovered that, if the image is in bitmap format, then the file is incomplete (it's missing the header). So I need to reconstruct this header before I can save the data to a file, but I'm having a bit of difficulty.
According to the Wikipedia entry for BMP file format, the header is 14 bytes long and should contain the following:
Offset Data0x0000
"BM", for our intents and purposes0x0002
Size of the bitmap file in bytes0x0006
Dependant on the application creating the file0x0008
Dependant on the application creating the file0x000A
Offset of the image data/pixel array
I figured that the size of the bitmap file in bytes would be the size of the extracted image + the 14 bytes for the header, but I'm unsure what to write at 0x0006, 0x0008 and how to get the location of the pixel array to write at 0x000A.
I've read the article a few times, but I must admit my head is hurting a little. This is my first experience at doing this sort of thing. Can anybody help me work out how to get the pixel array location?