Jump to content
Sign in to follow this  
gczobel

GetPixel on HBITMAP

Recommended Posts

gczobel

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!

Share this post


Link to post
Share on other sites
ProgAndy

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

Share this post


Link to post
Share on other sites
gczobel

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)

Share this post


Link to post
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
Sign in to follow this  

×