Jump to content

Vossen

Active Members
  • Posts

    32
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Vossen got a reaction from Shogi in Get Pixel Color from Image   
    When I searched this forum, I couldn't find any way to get a pixel color from an image.
    Done some research and found this on a french AutoIt forum (http://www.autoitscript.fr/forum/viewtopic.php?f=3&t=2993&start=0)


    #include <GDIPlus.au3> $sv_ImageSource = @ScriptDir & "\Source.jpg" $iPosX = 253 $iPosY = 291 _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sv_ImageSource) MsgBox(0, "Pixel Color", _GDIPlus_BitmapGetPixel($hImage, $iPosX, $iPosY)) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) Local $tArgb, $pArgb, $aRet $tArgb = DllStructCreate("dword Argb") $pArgb = DllStructGetPtr($tArgb) $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb) Return "0x" & Hex(DllStructGetData($tArgb, "Argb"), 6) EndFunc
    Hope it will be useful for someone else too!
  2. Like
    Vossen got a reaction from yahaosoft in Get Pixel Color from Image   
    When I searched this forum, I couldn't find any way to get a pixel color from an image.
    Done some research and found this on a french AutoIt forum (http://www.autoitscript.fr/forum/viewtopic.php?f=3&t=2993&start=0)


    #include <GDIPlus.au3> $sv_ImageSource = @ScriptDir & "\Source.jpg" $iPosX = 253 $iPosY = 291 _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sv_ImageSource) MsgBox(0, "Pixel Color", _GDIPlus_BitmapGetPixel($hImage, $iPosX, $iPosY)) _GDIPlus_ImageDispose($hImage) _GDIPlus_ShutDown() Func _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) Local $tArgb, $pArgb, $aRet $tArgb = DllStructCreate("dword Argb") $pArgb = DllStructGetPtr($tArgb) $aRet = DllCall($ghGDIPDll, "int", "GdipBitmapGetPixel", "hwnd", $hBitmap, "int", $iX, "int", $iY, "ptr", $pArgb) Return "0x" & Hex(DllStructGetData($tArgb, "Argb"), 6) EndFunc
    Hope it will be useful for someone else too!
×
×
  • Create New...