Jump to content

GetPixel on HBITMAP


Recommended Posts

Hi!

Suppose that I have a bitmap on the clipboard and I obtain a handle to it:

$hBitmap = _ClipBoard_GetData($CF_BITMAP)

I want to check some pixels on the bitmap.

There is any way to obtain a DeviceContext in order to call "SelectObject" then "GetPixel" ??

Thanks in advance!

Link to comment
Share on other sites

I think this way :)

$DeskDC = _WinAPI_GetDC(0)
$UseDC = _WinAPI_CreateCompatibleDC($DeskDC)
_WinAPI_ReleaseDC($DeskDC)
_WinAPI_SelectObject($UseDC,$hBitmap)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Thanks!!! Work perfect.

I add a little example:

if _ClipBoard_IsFormatAvailable($CF_BITMAP) = False Then
        Exit(1)
    EndIf       
    $hBitmap = _ClipBoard_GetData($CF_BITMAP) 
    
    $DeskDC = _WinAPI_GetDC(0)
    $UseDC = _WinAPI_CreateCompatibleDC($DeskDC)
    _WinAPI_ReleaseDC(0, $DeskDC)
    _WinAPI_SelectObject($UseDC,$hBitmap)
    
    Local $Color = DLLCall("gdi32.dll","int","GetPixel","int",$UseDC ,"int",100,"int",100)
    MsgBox(0,"Color", Hex($Color[0],6) )
    
    _WinAPI_DeleteDC($UseDC)
    
    _ScreenCapture_SaveImage('c:\Screen.bmp', $hBitmap, True)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...