04-15-2005, 11:31 PM
Recently I was busy with a routine to read bmps, and I used the BMP Header as a type to extract it immediately easyily and simple. However this turned out to be the cause of many errors...
It seems when I get a type from a file that the type contains the wrong data. I compared this to what normal (lots of GETs) would return, and the results were quite different.
Here's the code I tested the different results with:
This was run on a completely normal 1024x768x3 picture (2.25MB).
The output was as follows:
Anyone has an idea on what might cause this? It caused me a lot of trouble already :-?
Thanks in advance.
It seems when I get a type from a file that the type contains the wrong data. I compared this to what normal (lots of GETs) would return, and the results were quite different.
Here's the code I tested the different results with:
Code:
#define UINT Unsigned Integer
Type tBitMapFileHeader
bfType As Unsigned Short
bfTotalSize As UINT
bfReservedI As Unsigned Short
bfReservedII As Unsigned Short
bfOffbits As UINT
biSize As UINT
biWidth As UINT
biHeight As UINT
biPlanes As Unsigned Short
biBitCount As Unsigned Short
biCompression As UINT
biSizeImage As UINT
biXpixelsPerMeter As UINT
biYpixelsPerMeter As UINT
biClrUsed As UINT
biClrImportant As UINT
End Type
Dim Z As tBitMapFileHeader
FF = FREEFILE
Open "images/testbmp.bmp" For BInary As #FF
Get #FF, , Z
CLose #FF
Print Z.bfType
Print Z.bfTotalSize
Print Z.bfReservedI
Print Z.bfReservedII
Print Z.bfOffbits
Print Z.biSize
Print Z.biWidth
Print Z.biHeight
Print Chr$(13)
Dim ashort As Short, aint As UINT
Open "images/testbmp.bmp" For Binary As #FF
Get #FF, , ashort: Print ashort
Get #FF, , aint: Print aint
Get #FF, , ashort: Print ashort
Get #FF, , ashort: Print ashort
Get #FF, , aint: Print aint
Get #FF, , aint: Print aint
Get #FF, , aint: Print aint
Get #FF, , aint: Print aint
Close #FF
Sleep
This was run on a completely normal 1024x768x3 picture (2.25MB).
The output was as follows:
Quote:19778The last row of numbers is correct, the first block isn't.
36
0
54
2621440
67108864
50331648
65536
19778
2359350
0
0
54
40
1024
768
Anyone has an idea on what might cause this? It caused me a lot of trouble already :-?
Thanks in advance.