Results 1 to 2 of 2

Thread: Getting first 1,1 pixel position of a bitmap in memory

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2003
    Posts
    601

    Getting first 1,1 pixel position of a bitmap in memory

    i know how to do it if its allready displayed by using GetPixel api. but how can I get first pixel position of a bitmap in memory.

  2. #2
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Getting first 1,1 pixel position of a bitmap in memory

    I usually use GetObjectA to get Bitmap information
    vb Code:
    1. Option Explicit
    2.  
    3. Private Type BITMAP '24 bytes
    4.    Type As Long
    5.    Width As Long
    6.    Height As Long
    7.    WidthBytes As Long
    8.    Planes As Integer
    9.    BitsPixel As Integer
    10.    Bits As Long
    11. End Type
    12.  
    13. Private Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" ( _
    14.    ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long
    15.  
    16. Sub TestGetObjectAPI(hBmp)
    17. Dim BM As BITMAP
    18.    GetObjectAPI hBmp, 24, BM
    19.    With BM
    20.       Debug.Print .Width
    21.       Debug.Print .Height
    22.       Debug.Print .BitsPixel
    23.       Debug.Print .WidthBytes 'includes any padding
    24.       'Size of the pixel data = WidthBytes * Height
    25.       Debug.Print .Bits '<-- the address of the pixel data
    26.    End With
    27. End Sub
    vb Code:
    1. Call TestGetObjectAPI(Me.Picture.handle)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width