- Physical size of Bitmap
- Posted by Allan M on October 12th, 2003
I have loaded a bitmap from a file using LoadImage.
The size of the bitmap can be obtained from BITMAP struct, in pixels.
But I want to find out the Physical size of the original bitmap (or
alternatively the resolution ).
How do I do this?
- Posted by Michael Winter on October 12th, 2003
"Allan M" wrote on 12 Oct 03:
The way I know that works is by examining the header of the file. The
MSDN Library (both on- and off-line versions) have the DIB file
formats, under the GDI > Bitmaps> Bitmap Structures section. The
BITMAP[INFO/V4/V5]HEADER structures contain the target resolution in
pixels per metre (BITMAPCOREINFO, which is out-dated, does not). The
problems with this approach is LoadImage might not load this part of
the bitmap in to memory (I haven't checked). I've looked for this
sort of thing myself before, and I've never found a Win32 API function
that will get this stuff for you so it's probably all up to you.
Good luck,
Mike
--
Michael Winter
M.Winter@[no-spam]blueyonder.co.uk (remove [no-spam] to reply)
- Posted by poppyto on October 13th, 2003
Use GetObject
)
Stef++
"Michael Winter" <M.Winter@[no-spam]blueyonder.co.uk> a écrit dans le
message de news: hplib.5090$I61.46081205@news-text.cableinet.net...
- Posted by Michael Winter on October 13th, 2003
"poppyto" wrote on 13 Oct 03:
I hadn't seen that function before, but according to the description
you can only get the required information when the bitmap object was
created with CreateDIBSection. I loaded a bitmap (that does have full
header details) with LoadImage, then used GetObject with a DIBSECTION
structure but only the BITMAP and not the needed BITMAPINFOHEADER data
was written.
Seems like my suggestion *is* necessary unless someone suggests
otherwise, of course.
Thanks for pointing that out though.
Mike
--
Michael Winter
M.Winter@[no-spam]blueyonder.co.uk (remove [no-spam] to reply)
- Posted by Lucian Wischik on October 13th, 2003
"Michael Winter" <M.Winter@[no-spam]blueyonder.co.uk> wrote:
There are two types of bitmap: device-independent, and
device-dependent.
The former can be loaded with LoadImage(LR_CREATEDIBSECTION) and
created with CreateDIBSection. They support GetObject(DIBSECTION) to
get all the headers, or GetObject(BITMAP) to get fewer headers.
The latter can be loaded with LoadBitmap and LoadImage() and created
with CreateBitmap and CreateDIBitmap. They only support
GetObject(BITMAP).
Hence: use LR_CREATEDIBSECTION and it'll work!
--
Lucian