Archived

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

File Position Pointer Madness

This topic is 6022 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