-
Mar 29th, 2002, 10:38 PM
#1
Thread Starter
Lively Member
GetBitmapDimensionEx
i have a problem. i'm using loadimage to--obviously--load an image. setting the dimensions to 0 will result in the api function using the default dimensions, which is good. the problem is, the actual dimensions won't appear if you try using GetBitmapDimensionEx, which is what i've been trying to do; it just gives zeros. it's so frustrating. it's like in dhtml how you have to initialize certain style properties before using them. i could take the easy way out and load the picture into a vb picturebox, but that's too slow and unprofessional. help, please?
-
Apr 2nd, 2002, 07:34 AM
#2
Here are a couple of examples of using GetBitmapDimensionEx.
http://www.codehound.com/vb/results/...ensionEx&V=203
Hope this helps.
-
Aug 13th, 2015, 11:44 PM
#3
Frenzied Member
Re: GetBitmapDimensionEx
Originally Posted by Hack
First off, I'm sorry to bump this, but I'm having the EXACT same problem as the guy you replied to, and I found this thread via a direct link from Google's search results as I searched for a solution to my problem. So I figure, that even if the threat is ancient, reusing it for me having the same problem is better than starting a new thread and wasting harddrive space on VBForum's server.
My problem is the same as the OP of this thread. I need to get the dimensions of a bitmap, loaded with LoadPicture (which produces an StdPicture object, who's internal bitmap object is accessible via the Handle property of the StdPicture object). Now the Width and Height properties of the StdPicture object are measured in Himetrics, and I don't want to waste time calculating pixel dimensions from these, so I figured I'd pass the StdPicture object's Handle parameter (which is an hBitmap handle) to the GetBitmapDimensionsEx API function. Unfortunately, the dimensions retrieved from this function are always 0 (for both width and height), even though the function's return value is 1 (which means it had NO ERROR). So I need to know, did Microsoft supply another API function for this very purpose, maybe one that's undocumented, or at least is so old that it no longer appears on the MSDN website? If so, please let me know. The link in your above post is broken. The page it goes to gives a 404 error.
-
Aug 14th, 2015, 03:06 AM
#4
Re: GetBitmapDimensionEx
Code:
Option Explicit
Private Type BITMAP
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type
Private Declare Function GetObjectW Lib "gdi32.dll" (ByVal hgdiobj As Long, ByVal cbBuffer As Long, ByRef lpvObject As Any) As Long
Private Sub Form_Activate()
Dim RV As Long, BM As BITMAP
With LoadPicture("Bitmap.bmp")
RV = GetObjectW(.Handle, LenB(BM), BM): Debug.Assert RV = LenB(BM)
Print Round(ScaleX(.Width, vbHimetric, vbPixels)); "x"; Round(ScaleY(.Height, vbHimetric, vbPixels))
Print BM.bmWidth; "x"; BM.bmHeight
End With
End Sub
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|