Archived

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

BMP files

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

Hey, I was just going to ask another question about .BMPs and saw this thread. I'm loading in 24 bit BMP's.

First problem was no big deal. The data was in BGR format, had to swap it.

My OpenGL just puts the texture on upside down so I don't have to flip it.

Things work fine as long as each scanline matches up with DWORD packing (8, 16, 32, but for some reason not 24). Here's the psuedocode for trying to remove the padding.

if( width * 3 % 4) //remainder == padding
fileRead( dummyData, 4 - (width * 3 % 4))

Anyone have any input? As far as I can tell, 24bit BMPs don't use compression, am I right?

Share this post


Link to post
Share on other sites
Okay. What Inormally do is read every value into unsigned char (max value = 255).

I use a loop like

for(int Y = 0; Y < BMPHeight; Y++)
{
for(X = 0; X < Width; X++)
{
for (y = 1; y < 4; y++)
{
//Load stuff
}
}
for(X = 0; X < Width % 4; X++)
{
//Load Stuff (same as above, should be)
}
}

This is saver as your method, because in your method you will always end up with a value in dummydata

------------------
Dance with me......

Share this post


Link to post
Share on other sites
I don't really know how bitmaps are stored, and I would like to write a program that reads and writes BMP files instead of using a load picture command or whatever.
I use Visual Basic and can program DirectX etc. so I know a fair bit about programming.

Can anyone explain how they are stored, and/or give me a demo that shows how to create bmp files.

Thanks
Freeride Designs

Share this post


Link to post
Share on other sites
Yeah, I'm basically doing the same thing. That code was just to remove the padding. The full deal is:


for(i = 0; i < height; j++)
{
for(j = 0); j < width; j++)
{
ReadRGBtriple(...)
}
if( width * 3 % 4) //remainder == padding
fileRead( dummyData, 4 - (width * 3 % 4))
}

I did this late last night. I was probably just doing something stupid. Just saw this thread and brought it up. Things are dead here at work and it's not late enough to sneak out for that four day Thanksgiving weekend.

Share this post


Link to post
Share on other sites