Morrison Posted October 4, 2011 Posted October 4, 2011 Hi! I´m having a picture of a type and for all apeareances of black I set 999999 into an array. Now I want to have the middle Value of the 999999 Values if several appear beneath so that I receive an 1 pixel drawn A. Or no 999999 beneath each other. Any suggestions? expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <ScreenCapture.au3> #include <WinAPI.au3> #include <File.au3> #include <Array.au3> Opt('MustDeclareVars', 1) Local $hBitmap, $hImage, $sImageType, $iX, $iY, $iXc, $iYc, $iMemo, $iPixelColor, $count, $File, $color1, $oForm, $color, $dc, $setpixel, $realesedc Local $hGraphic, $hBitmap, $hBackbuffer, $save, $hPen, $hWind $File = FileOpen(@ScriptDir & "\coords.txt", 2) _Main() Func _Main() _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\PicA.jpg') $sImageType = _GDIPlus_EncodersGetCLSID("JPG") $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) Local $aCoords[$iY][$iX] $oForm = GUICreate("GDI+", ($iX), ($iY)) GUISetBkColor(0xFFFFFF) GUISetState() $hWind = WinGetHandle($oForm) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWind) $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iX, $iY, $hGraphic) $hBackbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsClear($hBackbuffer, 0xFFFFFFFF) For $iXc = 0 To $iX - 1 For $iYc = 0 To $iY - 1 $iPixelColor = Hex(_GDIPlus_GetPixel($hImage, $iXc, $iYc), 6) If Dec($iPixelColor) < Dec('882829') Then ;$count = $count + 1 FileWrite($File, $iXc & "," & $iYc & @CRLF) $aCoords[$iYc][$iXc] = 999999 SetPixel($oForm, $iXc, $iYc, $color) $hPen = _GDIPlus_PenCreate(0xFF000000); _GDIPlus_GraphicsDrawLine($hBackbuffer, $iXc, $iYc, $iXc + 1, $iYc + 1, $hPen) _GDIPlus_GraphicsDrawLine($hGraphic, $iXc, $iYc, $iXc + 1, $iYc + 1, $hPen) Else $aCoords[$iYc][$iXc] = 0 EndIf Next Next $save = _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & '\Image1.jpg') Do Until GUIGetMsg() = $GUI_EVENT_CLOSE FileClose($File) _GDIPlus_Shutdown() For $iXc = 0 To $iX - 1 For $iYc = 0 To $iY - 1 If $aCoords[$iXc][$iYc] = 999999 Then For $iYc2 = $iYc To $iY - 1 If $aCoords[$iXc][$iYc2] = 0 Then ; $aCoords[$iYc][$iXc + Floor(($iXc2 - $iXc - 1) / 2)] = 777777 ; eher links ausgerichtet $aCoords[$iXc][$iYc + Floor(($iYc2 - $iYc) / 2)] = 777777 ; eher rechts ausgerichtet $iYc = $iYc2 ExitLoop EndIf Next EndIf Next Next ;~ ; jede "zeile" durchgehen ;~ For $iYc = 0 To $iY - 1 ;~ For $iXc = 0 To $iX - 1 ;~ ; wenn schwarz "beginnt" ;~ If $aCoords[$iYc][$iXc] = 999999 Then ;~ ; gehe von dort aus ($iXc) weiter nach rechts, höchstens bis zum Ende des bildes. ;~ For $iXc2 = $iXc To $iX - 1 ;~ ; Wenn jetzt wieder eine weißer pixel kommt, ist die schwarze linie vorbei. ;~ If $aCoords[$iYc][$iXc2] = 0 Then ;~ ; Jetzt nur noch den Mittelpunkt der Linie ermitteln (Linie ist $iXc2 [rechter endpunkt] - $iXc [linker startpunkt] lang) ;~ ; Davon nehmen wir die Hälfte und addieren das auf den startpunkt der linie. ;~ ; bsp: Linie geht von 5 bis 14. Linie ist also 9 px lang (=14-5). Jede hälfte ist dann 4,5 px lang. ;~ ; Die Mitte liegt dann bei 9,5 (=5+4,5). Wobei wir natürlich runden müssen. ;~ ; $aCoords[$iYc][$iXc + Floor(($iXc2 - $iXc - 1) / 2)] = 777777 ; eher links ausgerichtet ;~ $aCoords[$iYc][$iXc + Floor(($iXc2 - $iXc) / 2)] = 777777 ; eher rechts ausgerichtet ;~ $iXc = $iXc2 ;~ ExitLoop ;~ EndIf ;~ Next ;~ EndIf ;~ Next ;~ Next _ArrayDisplay($aCoords, '', -1, 0) EndFunc ;==>_Main ; Gibt eine Zeile im Memo-Fenster aus Func MemoWrite($sMessage = '') GUICtrlSetData($iMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite ; _GDIPlus_GetPixel Func _GDIPlus_GetPixel($hBitmap, $X, $Y) Local $result = DllCall($ghGDIPDLL, "int", "GdipBitmapGetPixel", "ptr", $hBitmap, "int", $X, "int", $Y, "dword*", 0) If @error Then Return SetError(1, 0, 0) Return SetError($result[0], 1, $result[4]) EndFunc ;==>_GDIPlus_GetPixel ;SetPixel Func SetPixel($oForm, $X, $Y, $color) $dc = DllCall("user32.dll", "int", "GetDC", "hwnd", $oForm) $setpixel = DllCall("gdi32.dll", "long", "SetPixel", "long", $dc[0], "long", $X, "long", $Y, "long", $color) $realesedc = DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "int", $dc[0]) EndFunc ;==>SetPixel
Morrison Posted October 4, 2011 Author Posted October 4, 2011 So that the horizontal line from the A even is shown as a line.
Moderators Melba23 Posted October 4, 2011 Moderators Posted October 4, 2011 Morrison, I am really struggling to understand what you want. The fact that you have no replies to your first post makes me think I am not alone! You seem to want to convert the image into a "black & white" array and then redraw it somehow using GDI - perhaps with some scaling? Could you explain more clearly what you are actually trying to do? Then you might get some comments. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Valuater Posted October 4, 2011 Posted October 4, 2011 ...I am really struggling to understand what you want. The fact that you have no replies to your first post makes me think I am not alone! ... I agree. Please give a little more clear and descriptive info... 8)
Morrison Posted October 4, 2011 Author Posted October 4, 2011 (edited) The type A has a 5 pixel width. And I want to convert it into an 1 pixel type. So there where the 777777 is is the middle of both sides to the edge, but not for the horizontal line of the A. So maybe that if 3 pix to the edge, that it is even for the upper and lower edges?!? Edited October 4, 2011 by Morrison
jchd Posted October 4, 2011 Posted October 4, 2011 Either I don't get it or this is the ground-zero specification for typeface scaling. Anyway, good luck making anything work on this logic basis. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Moderators Melba23 Posted October 4, 2011 Moderators Posted October 4, 2011 Morrison, This gets you an array scaled as I think you you asked for: expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <Color.au3> #include <Array.au3> ; Credit: Malkey for the basic GDI code While 1 $sBMP_Path = FileOpenDialog("Select BMP to invert", "M:\Program\Au3 Scripts", "Bitmaps (*.jpg)", 2) If @error Then MsgBox(64, "Info", "No BMP selected") Exit Else ExitLoop EndIf WEnd ; Load original image _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sBMP_Path) If @error Then MsgBox(16, "Error", "Could not load BMP file") _GDIPlus_Shutdown() Exit EndIf Global $GuiSizeX = _GDIPlus_ImageGetWidth($hImage) Global $GuiSizeY = _GDIPlus_ImageGetHeight($hImage) ; Array to hold all pixels of the image Global $aArray[$GuiSizeX][$GuiSizeY] ; Display original image $hBitmap_GUI = GUICreate("Original Bitmap", $GuiSizeX, $GuiSizeY, 100, 100, $WS_POPUP) GUISetState() $hGraphicGUI = _GDIPlus_GraphicsCreateFromHWND($hBitmap_GUI) $hBMPBuff = _GDIPlus_BitmapCreateFromGraphics($GuiSizeX, $GuiSizeY, $hGraphicGUI) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBMPBuff) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hImage, 0, 0, $GuiSizeX, $GuiSizeY) _GDIPlus_GraphicsDrawImage($hGraphicGUI, $hBMPBuff, 0, 0) ; Convert the image Local $hBitmap = Image_Convert_To_Array($hBMPBuff, 0, 0, $GuiSizeX, $GuiSizeY) ; Clear up _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hBitmap_GUI) ; Display the array _ArrayDisplay($aArray) ; Create mini array $iX = Int($GuiSizeX / 4) $iY = Int($GuiSizeY / 4) Global $aMiniArray[$iX][$iY] ; Copy over every 4th element For $i = 0 To $iX -1 For $j = 0 To $iY - 1 $aMiniArray[$i][$j] = $aArray[$i * 4][$j * 4] Next Next ; Display the result _ArrayDisplay($aMiniArray) Exit ; ------------- Func Image_Convert_To_Array($hImage2, $iStartPosX = 0, $iStartPosY = 0, $GuiSizeX = Default, $GuiSizeY = Default) Local $hBitmap1, $Reslt, $width, $height, $stride, $format, $Scan0, $v_Buffer, $v_Value, $iIW, $iIH $iIW = _GDIPlus_ImageGetWidth($hImage2) $iIH = _GDIPlus_ImageGetHeight($hImage2) If $GuiSizeX = Default Or $GuiSizeX > $iIW - $iStartPosX Then $GuiSizeX = $iIW - $iStartPosX If $GuiSizeY = Default Or $GuiSizeY > $iIH - $iStartPosY Then $GuiSizeY = $iIH - $iStartPosY $hBitmap1 = _GDIPlus_BitmapCloneArea($hImage2, $iStartPosX, $iStartPosY, $GuiSizeX, $GuiSizeY, $GDIP_PXF32ARGB) $Reslt = _GDIPlus_BitmapLockBits($hBitmap1, 0, 0, $GuiSizeX, $GuiSizeY, BitOR($GDIP_ILMREAD, $GDIP_ILMWRITE), $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") For $i = 0 To $GuiSizeX - 1 For $j = 0 To $GuiSizeY - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) ; Get colour value of pixel $v_Value = DllStructGetData($v_Buffer, 1) ; Set to Black or White depending on luminance If (_ColorGetRed($v_Value) * 0.3) + (_ColorGetGreen($v_Value) * 0.59) + (_ColorGetBlue($v_Value) * 0.11) > 126 Then $aArray[$j][$i] = 0 Else $aArray[$j][$i] = 1 EndIf Next Next _GDIPlus_BitmapUnlockBits($hBitmap1, $Reslt) EndFunc ;==>Image_Convert_To_Array Pretty rough and ready and the scaling is not perfect. Although the "A" topography seems to have survived I have no idea what kind of image you will get from that "mini" array for other letters. Over to you now! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Morrison Posted October 5, 2011 Author Posted October 5, 2011 (edited) Hi! When I use your script on bigger images I get an error. !>09:52:18 AutoIT3.exe ended.rc:-1073741819 >Exit code: -1073741819 Time: 13.092 Or (83) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aArray[$j][$i] = 0 ^ ERROR And the scaling is not the main reason. actually I want to fetch the necessary coords to remember the type, and by scaling I´m loosing too much information of the ori. image. Better would be an algorythm wich marks all points with same distance to the edge. Like, the type has a pix width of 5.. so the 3rd pix would be the middle one. expandcollapse popup#include <File.au3> #include <Array.au3> $count = 0 $count = 0 $count2 = 0 $double = 0 $start = 0 $cDifferences = 0 $cYzush = 0 $cut = 0 $cONE = 0 $cTWO = 0 Local $a1, $b1, $a2, $b2, $c1, $c2, $c3, $newLine, $akt, $aXY, $mR, $sX, $sY, $look, $Set Local $aNxy[1][8] Local $cC[1][2] Opt('MouseClickDownDelay', 1) Opt('MouseClickDelay', 1) ;Koordinaten in Array lesen If Not _FileReadToArray(@ScriptDir & '\coords.txt', $aXY) Then Dim $nofile = 0 MsgBox(4096, "Fehler", "Keine Koordinaten vorhanden. error:" & @error) ElseIf _FileReadToArray(@ScriptDir & '\coords.txt', $aXY) Then $nofile = 1 EndIf If Not _FileCreate(@ScriptDir & '\midCoords.txt') Then MsgBox(4096, "Fehler", "Fehler beim Erstellen/Zurücksetzen der txt.-Datei: " & @error) EndIf $fNewCoords = FileOpen(@ScriptDir & '\midCoords.txt', 9) If $fNewCoords = -1 Then MsgBox(0, "Fehler", "Die Datei konnte nicht geöffnet werden.") Exit EndIf Local $aCoords[($aXY[0] + 1)][7] $aNxy[0][0] = 'Nr.' $aNxy[0][1] = 'x' $aNxy[0][2] = 'y' $aNxy[0][3] = 'Times' $aNxy[0][4] = '1st X,y' $aNxy[0][5] = 'mid x' $aNxy[0][6] = 'last x,y' $aNxy[0][7] = 'mid-y' $aCoords[0][0] = 'Nr.' $aCoords[0][1] = 'x' $aCoords[0][2] = 'y' $aCoords[0][3] = 'Times' $aCoords[0][4] = 'cDiff' $aCoords[0][5] = 'Y-zus' $aCoords[0][6] = 'Y-Punkt' ; Punkt auf Strich For $n = 1 To $aXY[0] ReDim $cC[UBound($cC) + 1][2] $split = StringSplit($aXY[$n], ',', 1) $cC[$n][0] = $split[1] $cC[$n][1] = $split[2] ;Wenn nebenliegendes Y auch vorhanden If $split[2] - 1 = $cC[$n - 1][1] Then $cYzush = $cYzush + 1 Else $cYzush = 0 EndIf If $n - 1 = 0 Then $aCoords[$n][0] = $n $aCoords[$n][1] = $split[1] $aCoords[$n][2] = $split[2] $aCoords[$n][3] = 1 $aCoords[$n][4] = $cDifferences $aCoords[$n][6] = 1 $count = $count + 1 Else If $split[1] = $aCoords[($n - 1)][1] Then $count = $count + 1 $aCoords[$n][0] = $n $aCoords[$n][1] = $split[1] $aCoords[$n][2] = $split[2] $aCoords[$n][3] = $count $aCoords[$n - 1][4] = $cDifferences + 1 ;$aCoords[$n][5] = $YConn ;Y-conn $sXold = $aCoords[$n][1] $sYold = $aCoords[$n][2] If $count = 2 Then $aCoords[$n][6] = 1 EndIf ElseIf $split[1] <> $aCoords[($n - 1)][1] And $n > 1 Then $cDifferences = $cDifferences + 1 $aCoords[$n][0] = $n ;Stelle $aCoords[$n][1] = $split[1] ;X Coord $aCoords[$n][2] = $split[2] ;Y Coord $aCoords[$n][3] = 1 ;x n-mal $aCoords[$n - 1][4] = $cDifferences ;diff n-mal ;$aCoords[$n][5] = $YConn ;Y-conn $aCoords[$n - 2][6] = 1 ReDim $aNxy[UBound($aNxy) + 1][8] $aNxy[0][0] = 'Nr.' $aNxy[0][1] = 'M-x' $aNxy[0][2] = 'M-y' $aNxy[0][3] = 'Times' $aNxy[0][4] = '1st X,y' $aNxy[0][5] = 'mid x,y' $aNxy[0][6] = 'last x,y' $aNxy[0][7] = 'mid-y' ;Declare X-diff Array $aNxy[$cDifferences][0] = $cDifferences ;Stelle $aNxy[$cDifferences][3] = $count ;Times $aNxy[$cDifferences][4] = $aXY[$n - $count] ;1st X,y $aNxy[$cDifferences][5] = $aXY[$n - Ceiling($count / 2)] ;mid X,y $aNxy[$cDifferences][6] = $aXY[$n - 1] ;last X,y $count = 1 EndIf If $split[1] = $aCoords[($n - 1)][1] And $split[2] <> ($aCoords[($n - 1)][1] + 2) And $count > 2 And $aCoords[$n][6] = 1 Then $aCoords[$n - 2][6] = 1 EndIf EndIf ;Wenn 2 Y nebeneinander If $cYzush >= 2 Then $YConn = 1 Else $YConn = 0 EndIf If $cYzush = 0 Then $aCoords[$n - 1][5] = $YConn ;Y-conn EndIf ;Wenn Y mehr/gleich 2 nebeneinanderliegende If $YConn = 0 Then $aNxy[$cDifferences][7] = 1 ;Y verbunden Else $aCoords[$n - 1][5] = $YConn ;Y-conn $aNxy[$cDifferences][7] = 0 ;Y getrennt EndIf $aCoords[$n][5] = $YConn ;Y-conn If $aCoords[$n][2] = ($aCoords[$n - 1][2] + 1) And $n > 2 Then $cXzush = 1 Else $cXzush = 0 EndIf If $aCoords[$n][5] = 1 And $aCoords[$n - 1][5] = 0 Then $start = $aCoords[$n - 1][0] EndIf If $aCoords[$n][5] = 0 And $aCoords[$n - 1][5] = 1 Then $end = $aCoords[$n][0] $mid = Ceiling(Round(($end - $start) / 2)) $aCoords[$n - $mid][6] = 1 EndIf If $aCoords[$n][1] = $aCoords[$n - 1][1] And $aCoords[$n][2] <> ($aCoords[$n - 1][2] + 1) Then $cutA = $aCoords[$n][0] $aCoords[$n - 2][6] = 1 EndIf Next For $n = 1 To $aXY[0] If $aCoords[$n][1] = $aCoords[$n - 1][1] And $aCoords[$n][2] <> ($aCoords[$n - 1][2] + 1) Then $newLine = 1 EndIf If $aCoords[$n][1] <> $aCoords[$n - 1][1] Or $aCoords[$n][2] <> ($aCoords[$n - 1][2] + 1) Then $newLine = 0 $set = 0 EndIf Next For $n = 1 To $aXY[0] If $aCoords[$n][6] = 1 And $aCoords[$n][5] = 1 And $akt = 0 Then $start = $aCoords[$n - 1][0] ;ConsoleWrite($start & ',') $akt = 1 EndIf If $aCoords[$n][1] <> $aCoords[$n - 1][1] Or $aCoords[$n][4] <> $aCoords[$n - 1][4] Then $end = $aCoords[$n][0] $akt = 0 EndIf If $aCoords[$n][5] = 0 And $akt = 1 Then $end = $aCoords[$n][0] $mid = Ceiling(Round((($end - $start) / 2))) $a = $aCoords[$n][0] If $aCoords[$end][3] > 4 Then If $set = 0 Then $aCoords[$n - $mid][6] = 2 $a = $aCoords[$n - $mid][0] $set = 1 EndIf If $set = 1 And $a <> $aCoords[$n - $mid][0] Then $aCoords[$n - $mid][6] = 3 $set = 2 EndIf Else $aCoords[$n - $mid][6] = 1 EndIf $akt = 0 EndIf If $aCoords[$n][2] <> ($aCoords[$n - 1][2] + 1) Then $set = 0 EndIf Next For $n = 1 To $aXY[0] If $aCoords[$n][6] = 2 And $cTWO = 1 Then $aCoords[$n][6] = 3 $cTWO = 0 EndIf If $aCoords[$n][6] = 1 Then $cTWO = 0 EndIf If $aCoords[$n][6] = 2 Then $cTWO = 1 EndIf If $aCoords[$n - 1][6] = 1 And $aCoords[$n][6] = 1 Then $aCoords[$n - 1][6] = '' EndIf Next _ArrayDisplay($aCoords) ;_ArrayDisplay($aNxy) For $i = 1 To UBound($aNxy) - 1 FileWrite($fNewCoords, $aNxy[$i][5] & @CRLF) Next ;_1_ende ;~ $pNotepad = Run(@WindowsDir & "\Notepad.exe") ;~ $hNP = WinGetHandle($pNotepad) ;~ WinWait($hNP) ;~ $NPSize = WinGetPos($hNP) ;~ $pX = $NPSize[0] + 150 ;~ $pY = $NPSize[1] + 150 ;~ If $nofile = 1 Then ;~ For $x = 1 To $aXY[0] ;~ $datasplit = StringSplit($aXY[$x], ',', 1) ;~ MouseMove(($datasplit[1] + $pX), ($datasplit[2] + $pY), 1) ;~ MouseDown('left') ;~ Sleep(1) ;~ If $datasplit[1] <> $oldXcoord Then ;~ MouseUp('left') ;~ EndIf ;~ If $datasplit[2] <> $oldYcoord + 1 Then ;~ MouseUp('left') ;~ EndIf ;~ Next ;~ EndIf ;~ MouseUp('left') Edited October 5, 2011 by Morrison
Moderators Melba23 Posted October 5, 2011 Moderators Posted October 5, 2011 Morrison, Cannot help with the error code and I do not understand the array error as the array is sized to match the image: Global $GuiSizeX = _GDIPlus_ImageGetWidth($hImage) Global $GuiSizeY = _GDIPlus_ImageGetHeight($hImage) ; Array to hold all pixels of the image Global $aArray[$GuiSizeX][$GuiSizeY] I want to fetch the necessary coords to remember the typeNow that is a whole new problem. Are you trying to perform some kind of character recognition? I am not sure your "middle pixel" algorithm idea is a good one - what happens if you get a 4-pixel width? Do you take the 2nd or the 3rd pixel? Can you explain why you are trying to get the basic shape of these characters - we might be able to offer a better solution. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Morrison Posted October 6, 2011 Author Posted October 6, 2011 Hi! Ähm, 1st my english is not so good at all and I´m just hobbying Autoit! With this script I want to use it in some part of Font-Recognition..I´ve got thousands of fonts and now I´m printing evry type of every font in a .jpg and want to analyze and specify the typical marks of the Font-Type. Even handwriting. - If you get even numbers it would be best that 2nd and 3rd are alternating, or..? Or maybe that the fitting numbers are shown like in game "Minesweeper", somehow!? For that the worth of the array-field is depending on how many black pixel count next to them! In other ways maybe two for-next loops..one for horiz. and one for vert. ..i´m at..
Moderators Melba23 Posted October 6, 2011 Moderators Posted October 6, 2011 Morrison,So you are looking at character recognition. I have written a script to read the output of an application with custom-drawn data, but it only used a fixed size font with a limited range of characters and colours - certainly not "thousands of fonts"!I am not at all sure that AutoIt is suited to this kind of work - it would require a lot of Pixel* functions which are not the fastest ones in the toolkit. And I am not at all confident that your simple "scaling" idea to recognise the fonts will work.I am afraid that I am bowing out here. I wish you well in your endeavours, but an OCR project of this size is well beyond my capabilites - and certainly beyond my patience! Good luck. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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