Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: VB5,VB6
Expertise: Intermediate
Oct 20, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

GetBitmapInfo - Retrieve information on a bitmap

' This structure holds Bitmap information
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 GetObjectAPI Lib "gdi32" Alias "GetObjectA" (ByVal _
    hObject As Long, ByVal nCount As Long, lpObject As Any) As Long

' Get information on a bitmap
' PICT is the Picture property of a PictureBox control
' WIDTH, HEIGHT return the size of the bitmap
' COLORPLANES and BITSPERPIXELS return information on the resolution and color 
' palette.
' Example:
'    Dim wi As Long, he As Long, cp As Integer, bpp As Integer
'    GetBitmapInfo Picture1.Picture, wi, he, cp, bpp
'    Print "Width: " & wi
'    Print "Height: " & he
'    Print "Color Planes: " & cp
'    Print "Bits per Pixel: " & bpp

Sub GetBitmapInfo(pict As StdPicture, Width As Long, Height As Long, _
    ColorPlanes As Integer, BitsPerPixel As Integer)
    Dim bmp As BITMAP
    GetObjectAPI pict, Len(bmp), bmp
    Width = bmp.bmWidth
    Height = bmp.bmHeight
    ColorPlanes = bmp.bmPlanes
    BitsPerPixel = bmp.bmBitsPixel
End Sub
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date