BMP files

Started by
4 comments, last by Freeride Designs 24 years, 4 months ago
just goto http://www.wotsit.org/ they have the specifications to the .bmp file format. Just read the file in as a regular binary file, flip it (because images are stored upside down in .bmp files) and then your all set.
Joseph FernaldSoftware EngineerRed Storm Entertainment.------------------------The opinions expressed are that of the person postingand not that of Red Storm Entertainment.
Advertisement
Thanks, that was exactly what I was looking for
----------------
Black Edge Games
----------------
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?

-the logistical one-http://members.bellatlantic.net/~olsongt
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......

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

----------------
Black Edge Games
----------------
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.

-the logistical one-http://members.bellatlantic.net/~olsongt

This topic is closed to new replies.

Advertisement