Advertisement

Reading BMP files

Started by November 07, 2000 03:07 AM
0 comments, last by Digger 24 years, 2 months ago
I am writing my own BMP loader, and have stumbled upon a very strange thing in reading the files. When I read the fileheader I get corrupted data from it. The ''BM'' characters is OK but when I get to the Size field it is getting out of hand. When I make the field 1 or 2 bytes long the variable gets its data correctly as it "should", but when I make the field 4 bytes long it looks like it "jumps" over 2 bytes and only saves the last 2 bytes. I thought this error was caused by the byte orders, but BMP files is in little endian just like x86 processors wants it. I have tried to read the file with both Windows API and iostream functions and it doesn''t work. I''m using Visual C++ 6 with Service Pack 4. What''s wrong? HELP ME, PLEASE!!!!!!!
I've had the same type of problem when trying to read in the information using a structure. This link
has my original question and the solution.

BTW, you can also change the struct byte alignment through Project, Settings, C++ (tab), Code Generation (in the Category ComboBox).

Hope this helps!

- Houdini


Edited by - Houdini on November 7, 2000 8:29:51 AM
- Houdini

This topic is closed to new replies.

Advertisement