flapsio Posted June 4, 2007 Share Posted June 4, 2007 Hi, I know about autoit functions for getting the pixel color of an image on screen. Is there a way of finding out the RGB color values for a given pixel of a bitmap file? Thanks. Link to comment Share on other sites More sharing options...
Gabburd Posted June 9, 2007 Share Posted June 9, 2007 Here's what you were looking for:http://www.autoitscript.com/forum/index.ph...=0&p=119090 Link to comment Share on other sites More sharing options...
eignxing Posted September 21, 2007 Share Posted September 21, 2007 The link you gave seems to be broken, but I found this collection of functions by evilertoaster which may be helpful.http://www.autoitscript.com/forum/index.ph...=27362&st=0Here is an example with the _PixelRead function:Replace "testimage.bmp" with your own.expandcollapse popup$bmp = _BMPOpen(@ScriptDir&"\testimage.bmp") $width = _BMPGetWidth($bmp) $height = _BMPGetHeight($bmp) MsgBox(0,"width", $width) MsgBox(0,"height", $height) $x = 0 $y = 0 Do Do $pixrd = _PixelRead($bmp,$x,$y) MsgBox(0, "$x: "&$x&"$y: "&$y, $pixrd) $y = $y + 1 Until $y = $height $x = $x + 1 $y = 0 Until $x = $width Func _BMPGetWidth(ByRef $BMPHandle) If IsArray($BMPHandle)=0 Then Return -1 If UBound($BMPHandle,0)<>2 Then Return -1 Return UBound($BMPHandle,1) EndFunc Func _BMPGetHeight(ByRef $BMPHandle) If IsArray($BMPHandle)=0 Then Return -1 If UBound($BMPHandle,0)<>2 Then Return -1 Return UBound($BMPHandle,2) EndFunc Func _BMPOpen($Path,$Progress=1) Local $Bpath=FileOpen($Path,4) If $Bpath=-1 then Return(-1) Local $TestBM=FileRead($Bpath,2) If $TestBM<>"BM" then Return(-2) Local $AllOf=FileRead($Bpath,FileGetSize($Path)) Local $Fixed="424D"&StringTrimLeft(String($AllOf),2) $x=Dec(FixFormat(StringMid($Fixed,37,8))) $y=Dec(FixFormat(StringMid($Fixed,45,8))) Dim $BMP[$x][$y] If $Progress=1 then ProgressOn("Loading BMP File...","","",-1,-1,18) for $c=$x to 0 step -4 If $c=3 then $TmpAdd="000000" ExitLoop EndIf If $c=2 then $TmpAdd="0000" ExitLoop EndIf If $c=1 then $TmpAdd="00" ExitLoop EndIf If $c=0 then $TmpAdd="" ExitLoop EndIf If $Progress=1 Then ProgressSet((($x+1)/($c+1))*100,"","Finding Add Amount ("&$c&" of "&$x&")") Next Local $addOffset=($y-1)*($c*2) For $a=0 to $Y-1 For $b=0 to $x-1 $te=109+((($x*($y-1-$a))+$B)*6)+$addOffset $BMP[$b][$a]=StringMid($Fixed,$te,6) Next $addOffset=$addOffset-($c*2) If $Progress=1 Then ProgressSet(($a/$y)*100,"","Line " & $a & " of " & $y) Next ProgressOff() Return $BMP EndFunc Func FixFormat($HexData) Local $a,$ReturnValue="" For $a=7 To 1 Step -2 $ReturnValue &= StringMid($HexData,$a,2) Next Return ($ReturnValue) EndFunc Func _PixelRead(ByRef $BMPHandle,$x,$y) Local $Width=UBound($BMPHandle,1) Local $Height=UBound($BMPHandle,2) If $x>$Width-1 Or $x<0 Or $y>$Height-1 Or $y<0 Then Return (-1) Local $type=Opt("ColorMode") If $type=1 Then $color=$BMPHandle[$x][$y] Else $temp=$BMPHandle[$x][$y] $color=StringMid($temp, 5, 2) & StringMid($temp, 3, 2) & StringMid($temp, 1, 2) EndIf If $color="" Then $Color="FFFFFF" Return $Color EndFuncHope that helps. 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