jjohn Posted February 6, 2006 Posted February 6, 2006 Could somebody see why when i get the pic converted data back to real pic the bottom row of pixels come ahead of the 1st row? to see this compile and run this #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) $panel = GUICreate("Pic scanner", @DesktopWidth, @DesktopHeight-250, 0, (@DesktopHeight-(@DesktopHeight-250))/2) GUISetBkColor (0xFFFFFF) GUICtrlCreatePic (@ScriptDir & "\pic.jpg", 0,221,40,21) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked" ) GUISetState() While 1 Sleep(1000) WEnd Func CLOSEClicked() Exit EndFunc Then this #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Dim $b1, $b2, $b0, $a, $a1 $b0 = 3 $b01 = 375 $b1 = 40 $b2 = 21 Dim $pa[$b1+2][$b2+2] $panel = GUICreate("Pic scanner", 1024, 768, -1, -1 ) GUISetBkColor (0xFFFFFF) GUICtrlCreatePic (@ScriptDir & "\pic.jpg", 5,5,40,21) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked" ) For $a = $b0 To $b0+$b1-1 For $a1 = $b01 To $b01+$b2-1 $pa[$a-$b0+1][$a1-$b01+1]=PixelGetColor ( $a , $a1) Next Next $a3 = GUICtrlCreateGraphic(0,0,600,400) For $a = $b0 To $b0+$b1-1 For $a1 = $b01 To $b01+$b2-1 GUICtrlSetGraphic ($a3,$GUI_GR_PIXEL,$a,$a1) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, '0x'&Hex($pa[$a-$b0+1][$a1-$b01+1],6)) Next Next GUISetState() While 1 Sleep(1000) WEnd Func CLOSEClicked() Exit EndFunc with the pic.jpg in folder Please help
Valuater Posted February 6, 2006 Posted February 6, 2006 (edited) i did something similar before here, i used your pic and took out my colored labels expandcollapse popup#include <GuiConstants.au3> Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client Opt("PixelCoordMode", 2) ;1=absolute, 0=relative, 2=client Dim $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") GUICreate("test window", 400, 300) GUICtrlCreateLabel("Array position", 5, 25) GUICtrlCreateLabel("$Ax and $Ay position", 110, 25) GUICtrlCreatePic(@ScriptDir &"\colors.jpg", 145, 0, 40, 21) ;GUICtrlSetBkColor(-1,0x00ff00); Green ;GUICtrlCreateLabel("", 145, 8, 28, 8) ;GUICtrlSetBkColor(-1,0xff0000) ; Red ;GUICtrlCreateLabel("", 145, 16, 28, 8) ;GUICtrlSetBkColor(-1,"") ; Black GUICtrlCreateLabel("RGB Mouse Color Found ", 250, 25) $color1 = GUICtrlCreateLabel("", 300, 3, 20, 20) $Edit1 = GUICtrlCreateEdit("", 50, 50, 300, 200) GUICtrlCreateLabel("Press *Pause* to Stop/Resume or Press *ESC* to Exit ", 60, 270) GUISetState() _ocr(150, 0, 170, 20) $msg = GUIGetMsg() While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() WEnd Func _ocr($Ax, $Ay, $Dx, $Dy) $By = $Ay $width = $Dx - $Ax $length = $Dy - $Ay Dim $char[$width][$length] For $xwidth = 0 To $width -1 $Ax = $Ax +1 $Ay = $By For $xlength = 0 To $length -1 $char[$xwidth][$xlength] = Hex(PixelGetColor($Ax, $Ay), 6) GUICtrlCreateLabel("*", $xwidth, $xlength) GUICtrlCreateLabel("*", $Ax -4, $Ay) GUICtrlSetData($Edit1, "Hex Color at " & $Ax & " and " & $Ay & " is " & $char[$xwidth][$xlength] & @CRLF, 1) MouseMove($Ax + 2, $Ay) GUICtrlSetBkColor( $color1, (PixelGetColor($Ax, $Ay))) Sleep(100) $Ay= $Ay+1 Next Next Return $char EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc 8) Edited February 6, 2006 by Valuater
jjohn Posted February 6, 2006 Author Posted February 6, 2006 Thx valuater, yours ocr code is interesting,... but my major problem is converting the pic data back to a pic and it got the row of pixel, supposingly the last, on the 1st row of the pic, that's drive me nuts.
jjohn Posted February 6, 2006 Author Posted February 6, 2006 Never mind, i finally figured it out, just swap the 2 line GUICtrlSetGraphic ($a3,$GUI_GR_PIXEL,$a,$a1) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, '0x'&Hex($pa[$a-$b0+1][$a1-$b01+1],6)) [code=auto:0] then everything work fine! Thx
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