How can I get the size of a bitmap?
Hello, I have to get the width and height size of a bitmap.
Do you have an idea of how I could do that?
I tried the fonction GetBitmapDimensionEx() but it doesn''t work.
I know that the width and height are stored in the bitmap''s header, but how can I access them?
Thanks.
Easiest 2 ways I can think of:
1. Load the bitmap with LoadBitmap()/LoadImage() and get information about it with GetObject() (Or another similar function).
2. Open the file yourself and read the header (That''s what you suggested
). Here''s some code for doing that:
Now the BITMAPINFOHEADER structure has the info you want.
You can also read the header (Instead of skipping it) to make sure it''s really a bitmap:
BITMAPFILEHEADER fHeader;
// read the header here
if (fHeader.bfType != 0x4D42)
{
// not a bitmap...
}
- Goblineye Entertainment
The road to success is always under construction
1. Load the bitmap with LoadBitmap()/LoadImage() and get information about it with GetObject() (Or another similar function).
2. Open the file yourself and read the header (That''s what you suggested

|
Now the BITMAPINFOHEADER structure has the info you want.
You can also read the header (Instead of skipping it) to make sure it''s really a bitmap:
BITMAPFILEHEADER fHeader;
// read the header here
if (fHeader.bfType != 0x4D42)
{
// not a bitmap...
}
- Goblineye Entertainment
The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement