PDA

Click to See Complete Forum and Search --> : Help with GetBitmapDimensionEx


The Dude
May 1st, 2000, 10:27 PM
I am trying to get the dimensions in pixels of bitmap loaded into a picture box. I have tried everything I can think of to get GetBitmapDimensionEx to work, but I still get zeros for height and width and a return value of 1. I cannot find much documentation on the web about this function.

Can someone please help me with a simple example of how to get height and width of a bitmap. If there is a better way than to use GetBitmapDimensionEx, I would also be interested.

Thanks.
Scott

Sam Finch
May 1st, 2000, 11:09 PM
I got your Email this morning but I've had quite a hectic day and I havn't got around to answering.

I'm glad you posted, you confirmed my suspicion that it's a picturebox you're working with. Pictureboxes are evil microsoft contraptions that don't use the bitmaps interface properly, because microsoft know the insides of the bitmap object better than anyone who didn't write it.

basicly GetBitmapDimensionEx doesn't work on stdPictures(pictureBoxs' picture object) I've had some success using GetObject, you need to pass in a BITMAP Structure (in your API viewer) and the Dimensions come out there.

Stevie-O
May 2nd, 2000, 11:25 PM
Actually, the reason GetBitmapDimensionsEx doesn't work with picture boxes is simple, and quit clearly documented in the API SDK reference:


GetBitmapDimensionEx
The GetBitmapDimensionEx function retrieves the dimensions of a bitmap. The retrieved dimensions must have been set by the SetBitmapDimensionEx function.


So unless whoever creates the bitmap bothers to call SetBitmapDimensionEx:


SetBitmapDimensionEx
The SetBitmapDimensionEx function assigns preferred dimensions to a bitmap. These dimensions can be used by applications; however, they are not used by the system.


These functions are, effectively, useful only for storing application-defined values in a bitmap. Why MS decided to implement them is beyond me.