Archived

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

Yet another newbie bmp loading question...

This topic is 5815 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 am now on chapter 9 of Tricks of the Windows Game Programming Gurus. Before completeing this chapter I want to mess around with all of the stuff I have learnt so far and create my own demo. I can load all of Andre''s bmp no problems at all, but when I try to make my own bmp in photoshop and save it as 8bit 256 colors etc. my application crashes at this line of code... // copy image to work area memcpy(buffer,image,bytes_per_line*height); in the Flip_Bitmap function called from Load_Bitmap_File function. These functions can be found in his t3dlib1.cpp file from chapter 8. Does anyone know what is going on here? Please help.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
probably because of the bit depth, i believe andre made his exclusively for 24 bit bmps

Share this post


Link to post
Share on other sites
The t3dlib1.cpp load bit map function works for all of his 8 bit bmp''s. I think I will have a look ahead at his final library and see if the function is any different, but I would be interested to know why this particualr case does not work. I would post the functions so that you could all see them, but I don''t want to get done for copywrite infringment. Does anyone know of any good resources that explain in lamens terms all about loading bmp''s? examples of doing so would be nice to.

Share this post


Link to post
Share on other sites
I made sure that my bitmap was 640 by 480 and that it was 8 bit and 256 colors. Would it be wrong of me to post his code and the bitmap I am trying to load? It may be easier that way, but I don''t want to get into any copy right issues. between school and this I have not had a lot of time to explore the various possibilities of why the bitmap is not loading, but this weekend I plan on donating a bunch of time to it. Does anyone know of any online resources that may help me? Has anyone fallen into similar issues as I am falling into?

Share this post


Link to post
Share on other sites
Alright I have narrowed down my problem even farther...

My problem actually occurrs here...

// finally the image data itself
if(_lseek(file_handle,-(int)(bitmap->bitmapinfoheader.biSizeImage),SEEK_END) == -1L)
{
MessageBox(NULL, "Error", MB_OK, MB_TOPMOST);
}

I through this quick test in and found that I am failing on this line for certain bmp''s...

If you are familiar with Andre''s code this line of code can be found in the function Load_Bitmap_File of the t3dlib1.cpp file from chapter 8.

Share this post


Link to post
Share on other sites
Sorry for the number of posts I have made.

I just found out that lseek set the errno to EBADF Bad file number 9 meaning the file handle is invalid. so I think I am getting closer to solving this. Thank you all who have posted and tried to help me. Please still post if you think you know the solution to this because I am just a wee newbie and have a lot to learn still.

Share this post


Link to post
Share on other sites
Now i am really confused.

I went back and tested one of Andre LaMothe''s bmp''s and his bmp still sets the errno to EBADF and throes the error, but it loads fine. So I am back to square 1 again. When I load my bmp it definately fails on this line // copy image to work area
memcpy(buffer,image,bytes_per_line*height);

Just like I said before.

I am going to run a bunch of theral tests just so I don''t posts wasted posts.

Thank you in advance for everyones help.

Share this post


Link to post
Share on other sites