Win32 GDI GetPixel

BlitzMax Forums/BlitzMax Programming/Win32 GDI GetPixel

plash(Posted 2007) [#1]
Problem fixed, here's the finished code.


SuperStrict

Extern "win32"
	Function GetPixel:Int(hdc:Int, x:Int, y:Int)
End Extern


Global HDC_DESKTOP:Int = GetDC(0)


Local p:Int = dGetPixel(931, 709), r:Int, g:Int, b:Int
ApiRGB(p, r, g, b)

DebugLog p + "|" + r + ", " + g + ", " + b

p = PrepRGB(r, g, b)

DebugLog p + "|" + r + ", " + g + ", " + b


Function dGetPixel:Int(x:Int, y:Int)
	Return GetPixel(HDC_DESKTOP, x, y)
End Function

Function CompareColors:Int(Col1:Int, Col2:Int)
	If Col1 = Col2 Then Return 1 Else Return 0
End Function

Function PrepRGB:Int(Red:Int, Green:Int, Blue:Int)
	Return Red | Green Shl 8 | Blue Shl 16
End Function

Function ApiRGB(Pixel:Int, Red:Int Var, Green:Int Var, Blue:Int Var)
	Red = (Pixel Shr 0) & 255
	Green = (Pixel Shr  8) & 255
	Blue = (Pixel Shr 16) & 255
	
End Function



plash(Posted 2007) [#2]
See above comment.


plash(Posted 2007) [#3]
Finally got it... found the solution in an old source code file I used for testing some things.