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.

Recommended Posts

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.

Share on other sites
Thanks, that was exactly what I was looking for

Share on other sites

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 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++)
{
}
}
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 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 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.

• Forum Statistics

• Total Topics
628714
• Total Posts
2984357

• 23
• 11
• 10
• 13
• 14