Advertisement

BITMAPINFOHEADER crap

Started by January 02, 2001 09:45 PM
5 comments, last by cow_in_the_well 24 years ago
When loading a BMP manually (ie not using LoadImage), what do u do about this? The biSizeImage of the BITMAPINFOHEADER loaded in is 0. I looked in the MSDN and it says
quote: biSizeImage Specifies the size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps.
This is an 24bit bitmap file that loads fine in photoshop and paintbrush. All the other bitmapinfoheader parameters are fine. How can i get the size of the image in this case? ----------------------------- -cow_in_the_well ''When in doubt, empty your magazine.'' - Murphy''s Combat Law

- Thomas Cowellwebsite | journal | engine video

It''s in Delphi, but you get the idea:


dc := GetDc(0);
OffScreenDC := CreateCompatibleDC(dc);
with OffScreenBITMAPINFO do
begin
biSize := sizeof(TBITMAPINFOHEADER); // biSize o BITMAPINFOHEADER
biWidth := 640; // biWidth;
biHeight := 480; // biHeight;
biPlanes := 1; // biPlanes;
biBitCount := 16; // biBitCount
biCompression := BI_RGB; // biCompression;
biSizeImage := 0; // biSizeImage;
biXPelsPerMeter := 0; // biXPelsPerMeter;
biYPelsPerMeter := 0; // biYPelsPerMeter;
biClrUsed := 0; // biClrUsed;
biClrImportant := 0; // biClrImportant;
end;
BitmapInfo.bmiHeader := OffscreenBitmapInfo;
pOffScreenBITMAPINFO := @OffScreenBITMAPINFO;
OffScreen := CreateDIBSection(OffScreenDC, pOffScreenBitmapInfo^, DIB_RGB_COLORS,pbOffScreen, nil, 0);
GetDIBits(OffscreenDC, Offscreen, 0, 480, nil, lpbi^, DIB_RGB_COLORS);
GetMem(lpvBits,lpbi.bmiHeader.biSizeImage);


You have to create a dummy one and point it towards your BITMAPINFOHEADER. It automatically fills it in for you. Okay?


"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..."
"When you are willing to do that which others are ashamed to do, therein lies an advantage."
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
Advertisement
For uncompressed BMPs biSizeImage is usually set to 0. You can calculate the size of the image yourself by looking at the biWidth, biHeight, and biBitCount (Width * Height * Bytes needed for each pixel).

For compressed BMPs the biSizeImage will by the size of the image buffer, not the uncompressed image.


- Houdini
- Houdini
so...

DWORD bytes = bmpinfoheader.biWidth * bmpinfoheader.biHeight * bmpinfoheader.biBits ???

can someone help me convert the bits into bytes?

-----------------------------
-cow_in_the_well

''When in doubt, empty your magazine.'' - Murphy''s Combat Law

- Thomas Cowellwebsite | journal | engine video

8bits = 1 byte

"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
We are creating a Multi-player space strategy/shoot-em-up/RPG game.
Development is well under way and we do have a playable demo.
Always looking for help.
Digital Euphoria Soft

whoops duh ...sorry just can''t think properlly in hot weather

-----------------------------
-cow_in_the_well

''When in doubt, empty your magazine.'' - Murphy''s Combat Law

- Thomas Cowellwebsite | journal | engine video

Advertisement
also, since it''s 24 bit and no palette, it''s the file size - the size of BITMAPFILEHEADER and the size of BITMAPINFOHEADER!

I had to go through all this stuffs trying to put .bmp files into a custom file and getting it back out later!

This topic is closed to new replies.

Advertisement