numegil Posted May 20, 2009 Share Posted May 20, 2009 Hi, Quick question: I know of the PixelGetColor() method that can be used to get the color of a pixel on the screen, but does there exist a similar method for reading a pixel off of a saved bitmap (without opening it)? Thanks, -numegil Link to comment Share on other sites More sharing options...
Malkey Posted May 20, 2009 Share Posted May 20, 2009 Hi, Quick question: I know of the PixelGetColor() method that can be used to get the color of a pixel on the screen, but does there exist a similar method for reading a pixel off of a saved bitmap (without opening it)? Thanks, -numegilThis appears to be a way that works. The pixel colour is in hexadecimal colour format 0xAARRGGBB (Alpha, Red, Green, Blue). Alpha channel is for transparency. Fully opaque is hex FF. ; #include <GDIPlus.au3> Opt('MustDeclareVars', 1) Local $hBitmap _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromFile(@MyDocumentsDir & "\bmbluebut.gif"); Enter path/name of image file here. MsgBox(0, "", _GDIPlus_BitmapGetPixel($hBitmap, 1, 1)); 0,0 is top left corner pixel of image. ; Clean up resources _GDIPlus_ImageDispose($hBitmap) ; Shut down GDI+ library _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")) EndFunc ;==>_GDIPlus_BitmapGetPixel ; Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now