Jouni,
I hacked a lot and my conclusion are below:
1) MIF file type 2 are simple the images count seems reliable. The header is below, the first 4 longs of mif file. All bytes are little endian. So:
Ex: first 16 bytes of wordmobi2.mif:
Code:
42232334 02000000 10000000 10000000
-> magic number: 42232334 (B##4)
-> mif type: 02000000 (2)
-> next field offset: 10000000 (16)
-> image count: 10000000 (16, for this example)
After, we have the table listing all image positions and sizes:
Ex: offset 16 of wordmobi2.mif
Code:
90000000 971D0000 (image 0)
90000000 971D0000 (mask 0)
271E0000 310D0000 (image 1)
271E0000 310D0000 (mask 1)
...
-> offset from beginning of file: 90000000 (144)
-> size: 971D0000 (7575)
In this case, image and mask are equal and points to the same location.
Each image has its own header, with 32 bytes. It is easy to see the magic number (C##4) and the amount of bytes in the image, not counting header.
Ex: image section header for an image in wordmobi2.mif
Code:
43232334 01000000 20000000 771D0000
01000000 0B000000 00000000 00000000
-> magic number: 43232334 (C##4)
-> unkown
-> unkown
-> image size: 771D0000 (7543)
-> unkown
-> unkown (1, 4, 6, and sometimes 7)
-> unkown
-> unkown (I saw 0, 1, 4 here)
I analyzed *several* image headers and fields 6 and 8 sometimes change. But I couldn't see any relationship.
We may see non compressed images inside the file. And extract them easily. I did this for my own file (wordmobi2.mif). There is a program for extracting compressed svg but it not worked for me when I compressed my mif file. But it works for avkon2.mif (you need to change the first long of the image, from CE56FA03 to CC56FA03). Of course, this may be illegal and I will not publish the results here or even recommend that you do it. It is better to check the copyrights of the images first.
2) MIF type 3 (ROM?) does not have the images table. And its header seems to have 5 fields. I am guessing that the last field is some CRC. I tried CRC32 over some parts of the file but the CRC was different. Images are the next field, at position indicated by the third field in the header:
Ex (avkon2.mif):
Code:
42232334 03000000 14000000 5A040000
CF272810 ( ==> IMG start here 43232334 01000000 20000000)
-> magic number: B##4
-> mif type: 03000000 (3)
-> next field offset: 14000000 (20)
-> image count: 5A040000 (1114)
-> CRC ??: CF272810
So, the number of images is a mystery. Header says 1114 but I could find only 423 image marks (C##4). Multiple layers images ? I don't know. Moreover, Python 1.9.5 loads all 1114 images while Python 1.4.5 loads only 233 images.
3) I saw some files with mif type 1. They were similar to mif type 2.
So, that all, my mif hacker session ends here.
I changed ViewMBM just to test (attached) and several mifs could be opened.