[Solved] 24-bit BMP hasn't got padding!?
Posted: Sun Jan 15, 2017 1:54 pm
Hi.
I was testing to load bmp files. I have 4 bmp files, Agola.bmp, Test1.bmp, Test2.bmp, Test3.bmp in root directory. All bmp files are 24-bit bmp except Test3.bmp, Test3.bmp is a 32-bit bmp.
Now, the interesting part. I read all 24-bit bmp files have padding bits to make it 32-bits, but my files haven't!? .
This is the code to load my bmps:
Yes, the output is upside down but this is not a problem now. Still I can't understand, if 24-bit bmp files have padding, that should fail.
But it doesn't fail, surprisingly if I make the read size 1920 * 1080 * 4 and VBE_FindMode(1920, 1080, 32); it fails, draws broken image. But if I use the same 1920 * 1080 * 4 and VBE_FindMode(1920, 1080, 32); with Test3.bmp (32-bit bmp) it works.
If they have padding, how draw doesn't fail?
What's happening? help pls
I was testing to load bmp files. I have 4 bmp files, Agola.bmp, Test1.bmp, Test2.bmp, Test3.bmp in root directory. All bmp files are 24-bit bmp except Test3.bmp, Test3.bmp is a 32-bit bmp.
Now, the interesting part. I read all 24-bit bmp files have padding bits to make it 32-bits, but my files haven't!? .
This is the code to load my bmps:
Code: Select all
uint16_t mode = VBE_FindMode(1920, 1080, 24);
VBE_SetMode(mode);
uint8_t* fb = (uint8_t*) ModeInfo->PhysBase;
ext2_read_file("/Agola.bmp", 1920 * 1080 * 3, 54, fb);
But it doesn't fail, surprisingly if I make the read size 1920 * 1080 * 4 and VBE_FindMode(1920, 1080, 32); it fails, draws broken image. But if I use the same 1920 * 1080 * 4 and VBE_FindMode(1920, 1080, 32); with Test3.bmp (32-bit bmp) it works.
If they have padding, how draw doesn't fail?
What's happening? help pls