Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

level10boy

File Position Pointer Madness

This topic is 6238 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have recently rewritten my 8bit bitmap file loading module that I''m using for a 2D DirectX sprite engine. The original functions worked fine using 16bit windows file I/O functions such as OpenFile and _lread but when I rewrote the loading function to use C++''s fstream classes and C''s (fopen and fread) the function would no longer work correctly. I traced the problem and found that the file position pointer was behaving erratically. The BITMAPFILEHEADER and BITMAPINFOHEADER load fine but on the third invoke of fread, to read the palette data, being an 8bit .bmp file, the file position pointer seems to jump when reading palette entry 220. I discovered this by printing the position of the file pointer after every read using ftell. After reading 219 RGBQUAD structures with the third invoke of fread, the file position pointer jumps to 4240 instead of 1078 for 256 entries. Does anyone out there know why this is happening? A similar scenario occurs also when using istream::read. Thankz, level10boy

Share this post


Link to post
Share on other sites
Advertisement
You''re probably not opening the stream in binary mode. Add ios::binary to the mode paramater when you open the stream.

-Mike

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!