• Advertisement

Archived

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

Loading BMP's without glaux

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

Im having trouble loading BMP''s without the glaux library. I can load the file headers and hte image data, but when I try and render the texture, the color format seems to be BGR instead of RGB. I thought I could get round this by just fliping the Red color bits for the Blue color bits, but this has proved more dificult than it sounds. The BMP was 24bit and had no alpha, I tried fliping every 3rd byte, then evry 4th, 2nd, 5th, 6th and even every byte. It looked slightly better with every byte fliped, but, all the other attemps ended in nasty lines running though my texture. What exactly am I supposed to do to correct the colors?

Share this post


Link to post
Share on other sites
Advertisement
Hi

you could try letting OpenGL handle this by using GL_BGR_EXT in glTexImage2D

alternatively you can read my bmp tutorial and use my function to convert the bmp buffer to a RGB buffer



Runicsoft -- home of my open source Function Parser and more

Share this post


Link to post
Share on other sites
Bitmaps store their colors as blue-green-red. So read blue first, then green, then red.

Also, don''t forget about bitmap padding. If the width of your bitmap, multiplied by bytes per pixel (3 for 24-bit bitmaps), is not evenly divisible by 4, then there will be extra useless bytes added onto each line to make it DWORD-aligned.

Example: Say your bitmap is 30 pixels wide, and it''s a 24-bit bitmap. The size of each line in bytes is 30*3 = 90 bytes. That is not evenly divisible by 4, so two bytes are added to each line to make it DWORD-aligned (92/4 = 23).

If you want a detailed example of loading all color formats of bitmaps, with padding in mind, check out the function I wrote for it.

~CGameProgrammer( );

Share this post


Link to post
Share on other sites

  • Advertisement