NeoFoX Posted January 25, 2008 Author Share Posted January 25, 2008 I'm working on it right now. It seems like there is a problem with the ImageGetInfo.au3 file from LazyCat.. it's not giving the correct/any values from the .jpg files! After this is fixed, you'll notice it! [center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center] Link to comment Share on other sites More sharing options...
NeoFoX Posted January 25, 2008 Author Share Posted January 25, 2008 Anyway, failing to solve the non-functionality myself, and guessing that the problem is somewhere within LazyCat's UDF (and that it's therefore unlikely even NeoFoX will be able to help get it working for non-gif files), I'll just post my version here as well instead of making a new thread (not in an attempt to hijack your thread, NeoFoX), in case anyone wants a screen-capture version rather than an image-load version of a b/w Ascii Art creator. This is based on my "draw in HTML" script I posted here. I HIGHLY recommend that if you're running this in Vista, compile it first, then right-click the .exe and under 'compatability' tab, choose to 'disable desktop composition'. expandcollapse popup#Include <GUIConstants.au3> #Include <Misc.au3> #Include <Color.au3> Global $AsciiChars[17]=["M","N","D","8","O","Z","$","7","I","?","+","=","~",":",",","."," "] #region GUICreation Global $TGUI = GUICreate("T Screen Capture",200,1,100,100,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) Global $LGUI = GUICreate("L Screen Capture",1,200,100,100,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) Global $BGUI = GUICreate("B Screen Capture",200,1,@DesktopWidth-300,@DesktopHeight-100,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) Global $RGUI = GUICreate("R Screen Capture",1,200,@DesktopWidth-100,@DesktopHeight-300,$WS_POPUP,BitOR($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUISetState(@SW_SHOW,$TGUI) GUISetState(@SW_SHOW,$LGUI) GUISetState(@SW_SHOW,$BGUI) GUISetState(@SW_SHOW,$RGUI) Global $ConfigGUI = GUICreate("Config Capture to ASCII by james3mg",300,300) GUICtrlCreateLabel("Please set the options for your screen capture",3,3,300,20) GUICtrlCreateLabel("Top Y",60,25,50,20) $TopInput=GUICtrlCreateInput("100",60,40,50,20) GUICtrlCreateUpDown($TopInput,$UDS_NOTHOUSANDS) GUICtrlCreateLabel("",60,65,40,1) GUICtrlSetBkColor(-1,0xFF0000) GUICtrlCreateLabel("Left X",5,60,50,20) $LeftInput=GUICtrlCreateInput("100",5,80,50,20) GUICtrlCreateUpDown($LeftInput,$UDS_NOTHOUSANDS) GUICtrlCreateLabel("",60,65,1,40) GUICtrlSetBkColor(-1,0xFF0000) $ClickTL=GUICtrlCreateButton("Click"&@CRLF&"to set",5,25,40,30,$BS_MULTILINE) GUICtrlCreateLabel("Bottom Y",200,250,50,20) $BottomInput=GUICtrlCreateInput(@DesktopHeight-100,200,270,50,20) GUICtrlCreateUpDown($BottomInput,$UDS_NOTHOUSANDS) GUICtrlCreateLabel("",200,240,40,1) GUICtrlSetBkColor(-1,0xFF0000) GUICtrlCreateLabel("Right X",245,200,50,20) $RightInput=GUICtrlCreateInput(@DesktopWidth-100,245,220,50,20) GUICtrlCreateUpDown($RightInput,$UDS_NOTHOUSANDS) GUICtrlCreateLabel("",240,200,1,40) GUICtrlSetBkColor(-1,0xFF0000) $ClickBR=GUICtrlCreateButton("Click"&@CRLF&"to set",255,255,40,30,$BS_MULTILINE) GUICtrlCreateLabel("Quality: (1 is best and biggest file)",70,150,160,20) $QualInput=GUICtrlCreateInput("1",70,165,50,20) GUICtrlCreateUpDown($QualInput) GUICtrlSetLimit(-1,9,1) $OKButton=GUICtrlCreateButton("Go!",70,200,60,20) #endregion GUICreation #region ConfigLoop GUISetState(@SW_SHOW,$ConfigGUI) $Flashtimer=TimerInit() $Red=true While 1 If TimerDiff($Flashtimer) > 1000 Then If $Red Then GUISetBkColor(0xFFFFFF,$TGUI) GUISetBkColor(0xFFFFFF,$LGUI) GUISetBkColor(0xFFFFFF,$RGUI) GUISetBkColor(0xFFFFFF,$BGUI) Else GUISetBkColor(0xFF0000,$TGUI) GUISetBkColor(0xFF0000,$LGUI) GUISetBkColor(0xFF0000,$BGUI) GUISetBkColor(0xFF0000,$RGUI) EndIf $Red = NOT $Red $Flashtimer=TimerInit() EndIf Switch GUIGetMsg() Case 0 ContinueLoop Case $GUI_EVENT_CLOSE Exit Case $OKButton Global $Quality=Round(GUICtrlRead($QualInput)) Global $CaptureTL[2]=[GUICtrlRead($LeftInput),GUICtrlRead($TopInput)] Global $CaptureBR[2]=[GUICtrlRead($RightInput),GUICtrlRead($BottomInput)] ExitLoop Case $ClickTL GUISetState(@SW_HIDE,$TGUI) GUISetState(@SW_HIDE,$LGUI) GUISetState(@SW_HIDE,$BGUI) GUISetState(@SW_HIDE,$RGUI) GUISetState(@SW_HIDE,$ConfigGUI) Do ToolTip("Click to set the top-left corner") Until _IsPressed("01") ToolTip("") GUICtrlSetData($TopInput,MouseGetPos(1)) GUICtrlSetData($LeftInput,MouseGetPos(0)) GUISetState(@SW_SHOW,$TGUI) GUISetState(@SW_SHOW,$LGUI) GUISetState(@SW_SHOW,$BGUI) GUISetState(@SW_SHOW,$RGUI) GUISetState(@SW_SHOW,$ConfigGUI) Case $ClickBR GUISetState(@SW_HIDE,$TGUI) GUISetState(@SW_HIDE,$LGUI) GUISetState(@SW_HIDE,$BGUI) GUISetState(@SW_HIDE,$RGUI) GUISetState(@SW_HIDE,$ConfigGUI) Do ToolTip("Click to set the bottom-right corner") Until _IsPressed("01") ToolTip("") GUICtrlSetData($BottomInput,MouseGetPos(1)) GUICtrlSetData($RightInput,MouseGetPos(0)) GUISetState(@SW_SHOW,$TGUI) GUISetState(@SW_SHOW,$LGUI) GUISetState(@SW_SHOW,$BGUI) GUISetState(@SW_SHOW,$RGUI) GUISetState(@SW_SHOW,$ConfigGUI) Case Else WinMove($TGUI,"",GUICtrlRead($LeftInput),GUICtrlRead($TopInput)) WinMove($LGUI,"",GUICtrlRead($LeftInput),GUICtrlRead($TopInput)) WinMove($BGUI,"",GUICtrlRead($RightInput)-200,GUICtrlRead($BottomInput)) WinMove($RGUI,"",GUICtrlRead($RightInput),GUICtrlRead($BottomInput)-200) EndSwitch WEnd GUIDelete($TGUI) GUIDelete($LGUI) GUIDelete($BGUI) GUIDelete($RGUI) GUIDelete($ConfigGUI) #endregion ConfigLoop If $Quality < 1 Then Exit Sleep(500);otherwise you can catch some of the red flashing border as it disappears #region WriteHTML $pixChecked=0 $TheWebpage=FileOpen(@ScriptDir&"\ASCIIpic.html",2) FileWriteLine($TheWebpage,"<HTML><HEAD><TITLE>ASCII Picture by james3mg</TITLE></HEAD><BODY bgcolor=#FFFFFF><TABLE border='0' cellspacing='0' cellpadding='0'><TR><TD><FONT style='line-height:50%' size='-3'><PRE>") For $y=$CaptureTL[1] To $CaptureBR[1] Step $Quality For $x=$CaptureTL[0] To $CaptureBR[0] Step $Quality $Red=_ColorGetRed(PixelGetColor($x,$y)) $Green=_ColorGetGreen(PixelGetColor($x,$y)) $Blue=_ColorGetBlue(PixelGetColor($x,$y)) $Averaged=Round(($Red+$Green+$Blue)/3) $Index=Round($Averaged/15)-1 If $Index < 0 Then $Index = 0 If $Index > 16 Then $Index = 16 FileWrite($TheWebpage,$AsciiChars[$Index]) $pixChecked+=$Quality*$Quality TraySetToolTip(Round($pixChecked/(($CaptureBR[0]-$CaptureTL[0])*($CaptureBR[1]-$CaptureTL[1])),3)*100 & "% completed") Next FileWrite($TheWebpage,@CRLF) Next FileWriteLine($TheWebpage,"</TABLE></BODY></HTML>") FileClose($TheWebpage) Sleep(500) Run(@ComSpec & ' /c start "" "'&@ScriptDir & '\ASCIIpic.html', "", @SW_HIDE) TrayTip("","Launching created HTML file",10) Sleep(10000) #endregion WriteHTMLI've set it up so that it 'stretches' the image vertically as little as possible, and I find that setting the quality to 5 renders the closest-to-original-size, though it actually comes out looking best if you leave quality at 1, then zoom using your web browser to 20%... Nice Program! I have to admit it. But it's a bit slow (just like mine ) and you can't see how far it's with the processing and you still can switch between screens. That is the first thing what happened with my test, perhaps you could do something about that! Keep up the good work! [center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center] Link to comment Share on other sites More sharing options...
NeoFoX Posted January 25, 2008 Author Share Posted January 25, 2008 *Edit 25-01-2008: Now it's working again, just download the ImageGetInfo.au3 which is in the first post.Now the .jpg files are working correctly (thanx to LazyCat) [center][font="Arial"]--- The Neo and Only --- [/font][font="Arial"]--Projects---[/font]Image to Text converterText to ASCII converter[/center] Link to comment Share on other sites More sharing options...
Greenseed Posted January 26, 2008 Share Posted January 26, 2008 Nice done! i love converting my Photo and see the result... just for fun so great... You can have a Very, Very, Very, Very big Increase into performance if you drop Usage of PixelGetColor function....Look here: http://www.autoitscript.com/forum/index.php?showtopic=62681 was trying to play with GetPixelColor but a faster way... look my explanation about why PixelGetColor is slow.And other thing that will solve is:If i grab a 5000x6000 Picture and try convert, you have to put the Picture on the screen for PixelGetColor to work... So working the image into Memory will solve that issue too i don't thing is big work implement that from my script to our... and will be a much more better usage of PixelGet from Dll call, into our script Thx again for that super cool script GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You. Link to comment Share on other sites More sharing options...
ReaImDown Posted February 7, 2008 Share Posted February 7, 2008 (edited) Well done, I love it... Edited February 7, 2008 by ReaImDown [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
muhmuuh Posted February 10, 2008 Share Posted February 10, 2008 wow man you rock! nothing more to say (bow) I ran. I ran until my muscles burned and my veins pumped battery acid. Then I ran some more. Link to comment Share on other sites More sharing options...
EnigmaV8 Posted February 13, 2008 Share Posted February 13, 2008 Unbelievable!! HA HA!! Awesome! Before = After = Link to comment Share on other sites More sharing options...
Aassdd Posted February 14, 2008 Share Posted February 14, 2008 Awesome Link to comment Share on other sites More sharing options...
jerem488 Posted March 23, 2008 Share Posted March 23, 2008 Very good work.... Congratulations ! Qui ose gagneWho Dares Win[left]CyberExploit[/left] Link to comment Share on other sites More sharing options...
trinitrotoluen Posted March 28, 2009 Share Posted March 28, 2009 How can I fix these error ? >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "F:\Thang2\SOFT\PROGRAMMING\AutoIT\AutoIT - My work\image_to_text.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>00:35:36 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000409 OS:WIN_XP/Service Pack 3, v.5657 CPU:X86 ANSI) >Running AU3Check (1.54.14.0) from:C:\Program Files\AutoIt3 F:\Thang2\SOFT\PROGRAMMING\AutoIT\AutoIT - My work\image_to_text.au3(105,65) : WARNING: $WS_POPUP: possibly used before declaration. $image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ F:\Thang2\SOFT\PROGRAMMING\AutoIT\AutoIT - My work\image_to_text.au3(105,80) : WARNING: $WS_EX_TOPMOST: possibly used before declaration. $image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP,$WS_EX_TOPMOST) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ F:\Thang2\SOFT\PROGRAMMING\AutoIT\AutoIT - My work\image_to_text.au3(113,71) : WARNING: $PBS_SMOOTH: possibly used before declaration. $progressbar = GUICtrlCreateProgress (15,30,100,20,$PBS_SMOOTH) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ F:\Thang2\SOFT\PROGRAMMING\AutoIT\AutoIT - My work\image_to_text.au3(105,65) : ERROR: $WS_POPUP: undeclared global variable. $image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ F:\Thang2\SOFT\PROGRAMMING\AutoIT\AutoIT - My work\image_to_text.au3 - 1 error(s), 3 warning(s) !>00:35:36 AU3Check ended.rc:2 +>00:35:37 AutoIt3Wrapper Finished >Exit code: 0 Time: 1.331 Link to comment Share on other sites More sharing options...
GEOSoft Posted March 28, 2009 Share Posted March 28, 2009 How can I fix these error ?Add these lines to the top of the script #include<windowsconstants.au3> #include<ProgressConstants.au3> #include<GuiConstantsEx.au3> George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
trinitrotoluen Posted March 28, 2009 Share Posted March 28, 2009 Add these lines to the top of the script #include<windowsconstants.au3> #include<ProgressConstants.au3> #include<GuiConstantsEx.au3> Thank you but this script doesn't work ! I tested with this simple image Link to comment Share on other sites More sharing options...
ReaImDown Posted June 20, 2013 Share Posted June 20, 2013 I know this is an old topic - but it's a cool idea... The script on post #1 doesn't work though :-/ [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 20, 2013 Moderators Share Posted June 20, 2013 ReaImDown,And I am not surprised given that it dates from 6 years ago and was coded using AutoIt v3.2.10.0 - there have been quite a few changes to the language since then. If you really want to see it working then you will have to convert the code. This is not overly difficult - you will have to add a few #include files and change a few functions. Why not give it a go and see how you get on? 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 Link to comment Share on other sites More sharing options...
ReaImDown Posted June 20, 2013 Share Posted June 20, 2013 I will give it a shot when I get home - am traveling Canada atm lol [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
CoDuX Posted July 18, 2013 Share Posted July 18, 2013 It gives me error when I click convert : Line 105 $image= GuiCreate ..... lalallalalala Error variable used without being declared Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 18, 2013 Moderators Share Posted July 18, 2013 CoDuX,Welcome to the AutoIt forum. See my comment a few posts above - code from 6 years ago is unlikely to run without problems given the huge changes made to the language in that time. In your case I imagine that the error is caused because the includes have been split and the constants are now in their own separate include file. Which variable is giving you the error? That might help us to pinpoint what you need to do to fix it. 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 Link to comment Share on other sites More sharing options...
GreenCan Posted July 18, 2013 Share Posted July 18, 2013 It gives me error when I click convert : Line 105 $image= GuiCreate ..... lalallalalala Error variable used without being declared Here is the corrected code, I don't know what I changed precisely, I modified it a while ago but it works on the latest AutoIt version... Have fun, be aware that the process is relatively slow, so select small images, or wait until tomorrow image_get_info.au3 expandcollapse popup;=============================================================================== ; ; Description: Return JPEG, TIFF, BMP, PNG and GIF image common info: ; Size, Color Depth, Resolution etc. For JPEG files retreive ; additional information from exif tag (if exists). ; Parameter(s): File name ; Requirement(s): Autoit 3.104 beta (DllStruct) ; Return Value(s): On Success - string in format: ; ParamName=ParamValue ; Pairs are separated by LF char. For getting data can be used ; function _ImageGetParam($sData, $sParam), where ; $sData - string, returned by _ImageGetInfo ; $sParam - param name, for ex. Width ; On Failure sets @ERROR: ; 1 - Can't open image ; Return string become empty if no info found ; Author(s): Yudin Dmitry (Lazycat) ; Version: 2.5 ; Date: 25.01.2008 ; ;=============================================================================== Func _ImageGetInfo($sFile) Local $sInfo = "", $hFile, $nClr Local $ret = DllCall("kernel32.dll","int","CreateFile", _ "str",$sFile, _ "int",0x80000000, _ "int",0, _ "ptr",0, _ "int",3, _ "int",0x80, _ "ptr",0) If @error OR Not $ret[0] Then SetError(1) Return "" Endif Local $hFile = $ret[0] Local $p = _FileReadToStruct("ubyte[54]", $hFile, 0) Local $asIdent = StringSplit(Chr(0xFF) & Chr(0xD8) & " BM " & Chr(0x89) & "PNG GIF89 GIF87 II MM", " ") For $i = 1 To $asIdent[0] If _DllStructArrayAsString($p, 1, StringLen($asIdent[$i])) = $asIdent[$i] Then Select Case $i = 1 ; JPEG $sInfo = _ImageGetInfoJPG($hFile, FileGetSize($sFile)) Exitloop Case $i = 2 ; BMP $t = DllStructCreate("int;int;short;short;dword;dword;dword;dword", DllStructGetPtr($p, 1) + 18) _Add($sInfo, "Width", DllStructGetData($t, 1)) _Add($sInfo, "Height", DllStructGetData($t, 2)) _Add($sInfo, "ColorDepth", DllStructGetData($t, 4)) _Add($sInfo, "XResolution", Round(DllStructGetData($t, 7)/39.37)) _Add($sInfo, "YResolution", Round(DllStructGetData($t, 8)/39.37)) _Add($sInfo, "ResolutionUnit", "Inch") Exitloop Case $i = 3 ; PNG $sInfo = _ImageGetInfoPNG($hFile) Exitloop Case ($i = 4) or ($i = 5) ; GIF $t = DllStructCreate("short;short;ubyte", DllStructGetPtr($p, 1) + 6) _Add($sInfo, "Width", DllStructGetData($t, 1)) _Add($sInfo, "Height", DllStructGetData($t, 2)) $nClr = DllStructGetData($t, 3) _Add($sInfo, "ColorDepth", _IsBitSet($nClr, 0) + _IsBitSet($nClr, 1)*2 + _IsBitSet($nClr, 2)*4 + 1) Exitloop Case $i = 6 ; TIFF II $sInfo = _ImageGetInfoTIFF($hFile, 0) Exitloop Case $i = 7 ; TIFF MM $sInfo = _ImageGetInfoTIFF($hFile, 1) Exitloop EndSelect Endif Next DllCall("kernel32.dll","int","CloseHandle","int", $hFile) $p = 0 Return($sInfo) EndFunc ;=============================================================================== ; PNG Parser ;=============================================================================== Func _ImageGetInfoPNG($hFile) Local $sInfo = "", $nNextOffset = 8, $nBlockSize, $nID Local $nBPP, $nCol, $sAlpha, $nXRes, $nYRes, $sKeyword, $nKWLen Local $pBlockID = DllStructCreate("udword;udword") While $nID <> 0x49444154 ; IDAT (picture data) $pBlockID = _FileReadToStruct($pBlockID, $hFile, $nNextOffset) $nBlockSize = _IntR(DllStructGetData($pBlockID, 1)) $nID = _IntR(DllStructGetData($pBlockID, 2)) Select Case $nID = 0x49484452 ; IHDR $t = _FileReadToStruct("udword;udword;byte;byte;byte;byte;byte", $hFile, $nNextOffset + 8) _Add($sInfo, "Width", _IntR(DllStructGetData($t, 1))) _Add($sInfo, "Height", _IntR(DllStructGetData($t, 2))) $nBPP = DllStructGetData($t, 3) $nCol = DllStructGetData($t, 4) $sAlpha = "" If $nCol > 3 Then $nCol = $nCol - 4 $sAlpha = " + alpha" Endif If $nCol < 3 Then $nBPP = ($nCol + 1) * $nBPP _Add($sInfo, "ColorDepth", $nBPP & $sAlpha) _Add($sInfo, "Interlace", DllStructGetData($t, 7)) Case $nID = 0x70485973 ; pHYs $t = _FileReadToStruct("udword;udword;ubyte", $hFile, $nNextOffset + 8) $nXRes = _IntR(DllStructGetData($t, 1)) $nYRes = _IntR(DllStructGetData($t, 2)) If DllStructGetData($t, 3) = 1 Then $nXRes = Round($nXRes/39.37) $nYRes = Round($nYRes/39.37) Endif _Add($sInfo, "XResolution", $nXRes) _Add($sInfo, "YResolution", $nYRes) _Add($sInfo, "ResolutionUnit", "Inch") Case $nID = 0x74455874 ; tEXt $t = _FileReadToStruct("char[80]", $hFile, $nNextOffset + 8) $sKeyword = DllStructGetData($t, 1) $nKWLen = StringLen($sKeyword) + 1 $t = 0 $t = _FileReadToStruct("char[" & $nBlockSize & "]", $hFile, $nNextOffset + 8 + $nKWLen) _Add($sInfo, $sKeyword, DllStructGetData($t, 1)) $nBlockSize = $nBlockSize + $nKWLen Case $nID = 0x74494D45 ; tIME $t = _FileReadToStruct("ushort,ubyte,ubyte,ubyte,ubyte,ubyte", $hFile, $nNextOffset + 8) _Add($sInfo, "DateTime", StringFormat("%4d:%02d:%02d %02d:%02d:%02d", _ DllStructGetData($t, 1), DllStructGetData($t, 2), _ DllStructGetData($t, 3), DllStructGetData($t, 4), _ DllStructGetData($t, 5), DllStructGetData($t, 6))) EndSelect $nNextOffset = $nNextOffset + 12 + $nBlockSize $t = 0 Wend $pBlockID = 0 Return $sInfo EndFunc ;=============================================================================== ; JPEG Parser ;=============================================================================== Func _ImageGetInfoJPG($hFile, $nFileSize) Local $anSize[2], $sData, $sSeg, $nPos = 2, $sInfo = "" Local $sUnit = "Pixel", $nMarker = 0, $nComLen Local $p = DllStructCreate("ubyte;ubyte;ushort;byte[128]") While ($nMarker <> 0xDA) and ($nPos < $nFileSize) $p = _FileReadToStruct($p, $hFile, $nPos) If DllStructGetData($p, 1) = 0xFF Then ; Valid segment start $nMarker = DllStructGetData($p, 2) Select Case ($nMarker = 0xC0) or ($nMarker = 0xC1) or ($nMarker = 0xC2) or _ ($nMarker = 0xC3) or ($nMarker = 0xC5) or ($nMarker = 0xC6) or _ ($nMarker = 0xC7) or ($nMarker = 0xCB) or ($nMarker = 0xCD) or _ ($nMarker = 0xCE) or ($nMarker = 0xCF) $t = DllStructCreate("align 1;byte;ushort;ushort", DllStructGetPtr($p, 4)) _Add($sInfo, "Width", _IntR(DllStructGetData($t, 3))) _Add($sInfo, "Height", _IntR(DllStructGetData($t, 2))) Case $nMarker = 0xE0 ; JFIF header $t = DllStructCreate("byte[5];byte;byte;ubyte;ushort;ushort", DllStructGetPtr($p, 4)) $nUnit = _IntR(DllStructGetData($t, 4)) If $nUnit = 1 Then $sUnit = "Inch" ElseIf $nUnit = 2 Then $sUnit = "Cm" EndIf _Add($sInfo, "XResolution", _IntR(DllStructGetData($t, 5))) _Add($sInfo, "YResolution", _IntR(DllStructGetData($t, 6))) _Add($sInfo, "ResolutionUnit", $sUnit) Case $nMarker = 0xE1 ; EXIF segment $sInfo = $sInfo & ParseExif($hFile, $nPos) Case $nMarker = 0xFE ; Comment segment $nComLen = _IntR(DllStructGetData($p, 3)) - 2 $t = _FileReadToStruct("byte[" & $nComLen & "]", $hFile, $nPos + 4) _Add($sInfo, "Comment", _DllStructArrayAsString($t, 1, $nComLen)) $t = 0 Case Else EndSelect $nPos= $nPos + _IntR(DllStructGetData($p, 3)) + 2 Else ExitLoop Endif Wend $p = 0 Return($sInfo) EndFunc ;=============================================================================== ; TIFF Parser ;=============================================================================== Func _ImageGetInfoTIFF($hFile, $nByteOrder) Local $anSize[2], $pos = 2, $sInfo = "", $aTag[1][2] _AddPair($aTag, 0x0100, "Width") _AddPair($aTag, 0x0101, "Height") _AddPair($aTag, 0x011A, "XResolution") _AddPair($aTag, 0x011B, "YResolution") _AddPair($aTag, 0x0132, "DateTime") _AddPair($aTag, 0x0131, "Software") _AddPair($aTag, 0x8298, "Copyright") $pHdr = _FileReadToStruct("short;short;dword", $hFile, 0) $nTagsOffset = _IntR(DllStructGetData($pHdr, 3), $nByteOrder) $pCount = _FileReadToStruct("ushort", $hFile, $nTagsOffset) $nFieldCount = _IntR(DllStructGetData($pCount, 1), $nByteOrder) $pTag = DllStructCreate("ushort;ushort;udword;udword") For $i = 0 To $nFieldCount - 1 $pTag = _FileReadToStruct($pTag, $hFile, $nTagsOffset + 2 + 12 * $i) $id = _IntR(DllStructGetData($pTag, 1), $nByteOrder) For $j = 1 To $aTag[0][0] If $aTag[$j][0] = $id Then _Add($sInfo, $aTag[$j][1], _ReadTag($hFile, $pTag, 0, $nByteOrder)) ; Tiff header at 0 offset Exitloop Endif Next If $id = 0x0102 Then If _IntR(DllStructGetData($pTag, 3), $nByteOrder) = 3 Then $t = _FileReadToStruct("short;short;short", $hFile, _IntR(DllStructGetData($pTag, 4), $nByteOrder)) _Add($sInfo, "ColorDepth", _IntR(DllStructGetData($t, 1), $nByteOrder) + _IntR(DllStructGetData($t, 2), $nByteOrder) + _IntR(DllStructGetData($t, 3), $nByteOrder)) $t = 0 Else _Add($sInfo, "ColorDepth", _IntR(DllStructGetData($pTag, 4), $nByteOrder)) Endif Endif If $id = 0x0128 Then _AddSpecial($sInfo, $id, _ReadTag($hFile, $pTag, 0, $nByteOrder)) Next Return($sInfo) Endfunc ;=============================================================================== ; EXIF Parser ;=============================================================================== Func ParseExif($hFile, $exif_offset) Local $ByteOrder = 0, $sInfo = "" Local $nEIFDOffset, $aTag[1][2] Local $sSpecialTags = "0112,8822,9208,9207,9209,9101,0128,A217,A403,A402,A406,A408,A409,A40A" _AddPair($aTag, 0x0100, "ExifWidth") _AddPair($aTag, 0x0101, "ExifHeight") _AddPair($aTag, 0x011A, "XResolution") _AddPair($aTag, 0x011B, "YResolution") _AddPair($aTag, 0x0102, "Colordepth") _AddPair($aTag, 0x0132, "DateTime") _AddPair($aTag, 0x9003, "DateTimeOriginal") _AddPair($aTag, 0x9004, "DateTimeDigitized") _AddPair($aTag, 0x9102, "CompressedBitsPerPixel") _AddPair($aTag, 0x9000, "ExifVersion") _AddPair($aTag, 0x9204, "ExposureBiasValue") _AddPair($aTag, 0x829A, "ExposureTime") _AddPair($aTag, 0x829D, "FNumber") _AddPair($aTag, 0x920A, "FocalLength") _AddPair($aTag, 0x8827, "ISO") _AddPair($aTag, 0x010F, "Make") _AddPair($aTag, 0x9202, "ApertureValue") _AddPair($aTag, 0x9205, "MaxApertureValue") _AddPair($aTag, 0x0110, "Model") _AddPair($aTag, 0x0131, "Software") _AddPair($aTag, 0x010E, "ImageDescription") _AddPair($aTag, 0x013B, "Artist") _AddPair($aTag, 0x8298, "Copyright") _AddPair($aTag, 0xA420, "ImageUniqueID") _AddPair($aTag, 0x9286, "UserComments") _AddPair($aTag, 0x9201, "ShutterSpeedValue") _AddPair($aTag, 0x9202, "ApertureValue") _AddPair($aTag, 0x9203, "BrightnessValue") _AddPair($aTag, 0x9206, "SubjectDistance") _AddPair($aTag, 0xA404, "DigitalZoomRatio") $nTiffHdrOffset = $exif_offset + 10 ; Start of TIFF header $pHdr = _FileReadToStruct("short;short;dword", $hFile, $nTiffHdrOffset) If DllStructGetData($pHdr, 1) = 0x4D4D then $ByteOrder = 1 $nIFDOffset = _IntR(DllStructGetData($pHdr, 3), $ByteOrder) $pCnt = _FileReadToStruct("ushort", $hFile, $nTiffHdrOffset + $nIFDOffset) ; Tags count $nIFDCount = _IntR(DllStructGetData($pCnt, 1), $ByteOrder) $pTag = DllStructCreate("ushort;ushort;udword;udword") For $nCnt = 0 To $nIFDCount - 1 $pTag = _FileReadToStruct($pTag, $hFile, $nTiffHdrOffset + $nIFDOffset + 2 + $nCnt * 12) $id = DllStructGetData($pTag, 1) $id = _IntR($id, $ByteOrder) For $i = 1 To $aTag[0][0] If $aTag[$i][0] = $id Then _Add($sInfo, $aTag[$i][1], _ReadTag($hFile, $pTag, $nTiffHdrOffset, $ByteOrder)) Exitloop Endif Next If StringInStr($sSpecialTags, Hex($id, 4)) Then _AddSpecial($sInfo, $id, _ReadTag($hFile, $pTag, $nTiffHdrOffset, $ByteOrder)) If $id = 0x8769 Then ; Exif IFD Offset $nEIFDOffset = _ReadTag($hFile, $pTag, $nTiffHdrOffset, $ByteOrder) $pCnt = _FileReadToStruct($pCnt, $hFile, $nTiffHdrOffset + $nEIFDOffset) $nEIFDCount = _IntR(DllStructGetData($pCnt, 1), $ByteOrder) Endif Next If not ($nEIFDOffset > 0) Then Return($sInfo) For $nCnt = 0 To $nEIFDCount - 1 $pTag = _FileReadToStruct($pTag, $hFile, $nTiffHdrOffset + $nEIFDOffset + 2 + $nCnt * 12) $id = DllStructGetData($pTag, 1) $id = _IntR($id, $ByteOrder) For $i = 1 To $aTag[0][0] If $aTag[$i][0] = $id Then _Add($sInfo, $aTag[$i][1], _ReadTag($hFile, $pTag, $nTiffHdrOffset, $ByteOrder)) Exitloop Endif Next If StringInStr($sSpecialTags, Hex($id, 4)) Then _AddSpecial($sInfo, $id, _ReadTag($hFile, $pTag, $nTiffHdrOffset, $ByteOrder)) Next $pHdr = 0 $pCnt = 0 $pTag = 0 Return($sInfo) EndFunc ;=============================================================================== ; Return multi-choice values for some tags ;=============================================================================== Func _AddSpecial(ByRef $sInfo, $ID, $nValue) Local $nIndex = $nValue, $sLabel, $aData, $sFired, $sMode, $sRed Select Case $id = 0xA402 $sLabel = "ExposureMode" $aData = StringSplit("Auto,Manual,Auto bracket,Undefined", ",") If $nValue > 2 Then $nIndex = 3 Case $id = 0xA403 $sLabel = "WhiteBalance" $aData = StringSplit("Auto,Manual,Undefined", ",") If $nValue > 1 Then $nIndex = 2 Case $id = 0xA406 $sLabel = "SceneCaptureType" $aData = StringSplit("Standard,Landscape,Portrait,Night scene,Undefined", ",") If $nValue > 3 Then $nIndex = 4 Case $id = 0xA408 $sLabel = "Contrast" $aData = StringSplit("Normal,Soft,Hard,Undefined", ",") If $nValue > 2 Then $nIndex = 3 Case $id = 0xA409 $sLabel = "Saturation" $aData = StringSplit("Normal,Low,High,Undefined", ",") If $nValue > 2 Then $nIndex = 3 Case $id = 0xA40A $sLabel = "Sharpness" $aData = StringSplit("Normal,Soft,Hard,Undefined", ",") If $nValue > 2 Then $nIndex = 3 Case $id = 0xA217 $sLabel = "SensingMethod" $aData = StringSplit("Undefined,Undefined,OneChipColorArea,TwoChipColorArea,ThreeChipColorArea,ColorSequentialArea,Undefined,Trilinear,ColorSequentialLinear", ",") If $nValue > 8 Then $nIndex = 0 Case $id = 0x9101 $sLabel = "ComponentsConfiguration" $aData = StringSplit("YCbCr,RGB", ",") $nIndex = 0 If StringLeft($nValue, 1) = 0x34 Then $nIndex = 1 Case $id = 0x0128 $sLabel = "ResolutionUnit" $aData = StringSplit("Undefined,Undefined,Inch,Sentimeter", ",") If $nValue < 2 or $nValue > 3 Then $nIndex = 0 Case $id = 0x0112 $sLabel = "Orientation" $aData = StringSplit("Undefined,Normal,Mirrored,180°,180° and mirrored,90° left and mirrored,90° right,90° right and mirrored,90° left", ",") If $nValue > 8 Then $nIndex = 0 Case $id = 0x8822 $sLabel = "ExposureProgram" $aData = StringSplit("Unknown,Manual Control,Normal,Aperture Priority,Shutter Priority,Creative (slow program),Action (high-speed),Portrait mode,Landscape mode", ",") If $nValue > 8 Then $nIndex = 0 Case $id = 0x9207 $sLabel = "MeteringMode" $aData = StringSplit("Unknown,Average,Center Weighted Average,Spot,MultiSpot,MultiSegment,Partial,Other", ",") If $nValue > 7 Then $nIndex = 7 Case $id = 0x9208 $sLabel = "LightSource" $aData = StringSplit("Unknown,Daylight,Fluorescent,Tungsten,Flash,Standard light A,Standard light B,Standard light C,D55,D65,D75,Other", ",") Select Case $nValue < 4 $nIndex = $nValue Case $nValue = 10 $nIndex = 4 Case $nValue > 16 and $nValue < 23 $nIndex = 5 + $nValue - 17 Case $nValue = 255 $nIndex = 11 Case Else $nIndex = 0 EndSelect Case $id = 0x9209 $sFired = "Not fired, " If _IsBitSet($nValue, 0) Then $sFired = "Fired, " $sMode = "" $nModeState = _IsBitSet($nValue, 4) * 2 + _IsBitSet($nValue, 3) If $nModeState = 1 Then $sMode = "Forced ON, " ElseIf $nModeState = 2 Then $sMode = "Forced OFF, " ElseIf $nModeState = 3 Then $sMode = "Auto, " Endif $sRed = "" If _IsBitSet($nValue, 6) Then $sRed = "Red-eye reduction, " $sInfo = $sInfo & StringTrimRight("Flash=" & $sFired & $sMode & $sRed, 2) & @LF Return EndSelect $sInfo = $sInfo & $sLabel & "=" & $aData[$nIndex+1] & @LF EndFunc ;=============================================================================== ; Parser for TIFF tags (not fully support multi-values tags) ;=============================================================================== Func _ReadTag($hFile, $pTag, $nHdrOffset, $ByteOrder) Local $nType = _IntR(DllStructGetData($pTag, 2), $ByteOrder) Local $nCount = _IntR(DllStructGetData($pTag, 3), $ByteOrder) Local $nOffset = _IntR(DllStructGetData($pTag, 4), $ByteOrder) Local $p, $vData = "" Select Case $nType = 2 ; ASCII String $p = _FileReadToStruct("char[" & $nCount & "]", $hFile, $nHdrOffset + $nOffset) $vData = DllStructGetData($p, 1) Case $nType = 1 or $nType = 3 or $nType = 4 ; Byte, short or long (unsigned) $vData = _IntR(DllStructGetData($pTag, 4), $ByteOrder) Case $nType = 5 ; Rational (unsigned long/long) $p = _FileReadToStruct("udword;udword", $hFile, $nHdrOffset + $nOffset) $vData = _IntR(DllStructGetData($p, 1), $ByteOrder) / _IntR(DllStructGetData($p, 2), $ByteOrder) Case $nType = 7 ; Undefined (byte * count) $p = _FileReadToStruct("char[" & $nCount & "]", $hFile, $nHdrOffset + $nOffset) $vData = _DllStructArrayAsString($p, 1, $nCount) Case $nType = 9 ; Signed long $p = _IntR(DllStructGetData($pTag, 4), $ByteOrder) $vData = _DllStructArrayAsString($p, 1, $nCount) Case $nType = 10 ; Rational (signed long/long) $p = _FileReadToStruct("dword;dword", $hFile, $nHdrOffset + $nOffset) $vData = _IntR(DllStructGetData($p, 1), $ByteOrder) / _IntR(DllStructGetData($p, 2), $ByteOrder) EndSelect $p = 0 Return $vData EndFunc ;=============================================================================== ; Get param by name from function result ;=============================================================================== Func _ImageGetParam($sData, $sParam) Local $nParamPos = StringInStr($sData, $sParam) If $nParamPos Then $sData = StringTrimLeft($sData, $nParamPos + StringLen($sParam)) Return StringLeft($sData, StringInStr($sData, @LF) - 1) Endif Return "" EndFunc ;=============================================================================== ; Checks if bit in the number is set ;=============================================================================== Func _IsBitSet($nNum, $nBit) Return BitAND(BitShift($nNum, $nBit), 1) EndFunc ;=============================================================================== ; Add pair of values ID - Label to array ;=============================================================================== Func _AddPair(ByRef $aTag, $nID, $sLabel) Local $nBound = UBound($aTag) ReDim $aTag[$nBound+1][2] $aTag[$nBound][0] = $nID $aTag[$nBound][1] = $sLabel $aTag[0][0] = $nBound EndFunc ;=============================================================================== ; Wrapper to add string ;=============================================================================== Func _Add(ByRef $sInfo, $sLabel, $nValue) $sInfo = $sInfo & $sLabel & "=" & $nValue & @LF EndFunc ;=============================================================================== ; Convert Intel numbers into Motorola in case $nOrder = 1 ;=============================================================================== Func _IntR($nInt, $nOrder = 1) If not $nOrder Then Return $nInt Local $nRet = 0, $nIntSize = 3 If BitShift($nInt, 16) = 0 Then $nIntSize = 1 For $i = 0 To $nIntSize $curbyte = BitAND(BitShift($nInt, 8 * ($nIntSize-$i)), 0xFF) $nRet = $nRet + BitShift($curbyte, -8 * $i) Next Return($nRet) EndFunc ;=============================================================================== ; Read data to struct given by string or pointer ;=============================================================================== Func _FileReadToStruct($vStruct, $hFile, $nOffset) If not DllStructGetSize($vStruct) Then $vStruct = DllStructCreate($vStruct) Local $nLen = DllStructGetSize($vStruct) Local $ret = DllCall("kernel32.dll","int","SetFilePointer", _ "int",$hFile, _ "int",$nOffset, _ "int",0, _ "int",0) ; FILE_BEGIN Local $pRead = DllStructCreate("dword") $ret = DllCall("kernel32.dll","int","ReadFile", _ "int",$hFile, _ "ptr",DllStructGetPtr($vStruct), _ "int", $nLen, _ "ptr",DllStructGetPtr($pRead), _ "ptr",0) Local $nRead = DllStructGetData($pRead, 1) $pRead = 0 SetExtended($nRead) If not ($nRead = $nLen) Then SetError(2) Return $vStruct EndFunc ;=============================================================================== ; Read string data, avoid situation when string is not null-terminated ;=============================================================================== Func _DllStructArrayAsString($p, $index, $size, $start = 1) Local $sTemp = "", $char For $i = $start to $size $char = DllStructGetData($p, $index, $i) If $char = 0 then Return $sTemp $sTemp &= Chr($char) Next Return $sTemp EndFunc and image_to_text.au3 expandcollapse popup#include <File.au3> #include <Guiconstants.au3> #include <image_get_info.au3> #include<windowsconstants.au3> #include<ProgressConstants.au3> #include<GuiConstantsEx.au3> Global $i_height,$i_width,$waardes,$total,$info,$image,$contrast_value,$contrast_value_end,$size Global $procent_pixels,$pixel_atm,$value_progress,$progressbar,$progress,$progress_count,$procent Global $bg_color,$font_color,$size_ASCII $Main = GUICreate("Image to Text", 629, 363, 193, 115) GUICtrlCreateGroup("Preview Image", 8, 8, 305, 345) $Picca = GUICtrlCreatePic("", 16, 32, 225, 209) $slider_procent = GUICtrlCreateSlider (25,256,200,20) GUICtrlSetState(-1,$GUI_DISABLE) $slider_procent_text = GUICtrlCreateLabel("",230,256,50,20) $Label9 = GUICtrlCreateLabel("% of pixels", 255, 255, 50, 17) $width_test = GUICtrlCreateLabel(" ", 36, 286, 30, 17) $Label2 = GUICtrlCreateLabel("x", 64, 286, 9, 17) $height_test = GUICtrlCreateLabel(" ", 80, 286, 30, 17) $file_size = GUICtrlCreateLabel(" ", 55, 310, 30, 17) $Label5 = GUICtrlCreateLabel("Kb", 75, 310, 17, 17) $Label6 = GUICtrlCreateLabel("Pixels", 128, 286, 31, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $tab_text =GUICtrlCreateTab (320,8, 305,345) $color_grayscale = GUICtrlCreateTabitem("Color / Grayscale") $browse = GUICtrlCreateButton("&Browse", 328, 32, 121, 33, 0) GUICtrlCreateGroup("Characters:", 328, 72, 257, 80) $characters = GUICtrlCreateInput("Characters", 336, 92, 100, 21) $char_size = GUICtrlCreateCombo("Smallest", 450, 92, 100, 25) GUICtrlSetData(-1,"Small|Normal|Large|Largest","Small") $random = GUICtrlCreateRadio("Random", 336, 120, 105, 25) GUICtrlSetState($Random, $GUI_CHECKED) $Sequence = GUICtrlCreateRadio("Sequence", 456, 120, 121, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Color:", 328, 160, 257, 95) $color = GUICtrlCreateRadio("Color", 336, 176, 97, 25) $grayscale = GUICtrlCreateRadio("Grayscale", 456, 176, 97, 25) GUICtrlSetState($color, $GUI_CHECKED) $Label7 = GUICtrlCreateLabel("Background:",336, 207, 193, 25) $bg_color = GUICtrlCreateCombo("BLACK", 336, 225, 193, 25) GUICtrlSetData(-1,"WHITE","BLACK") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Contrast:", 328, 260, 257, 49) $high = GUICtrlCreateRadio("High", 336, 276, 113, 25) $low = GUICtrlCreateRadio("Low", 456, 276, 113, 25) GUICtrlSetState($low, $GUI_CHECKED) GUICtrlCreateGroup("", -99, -99, 1, 1) $ok_button = GUICtrlCreateButton("&Convert", 328, 312, 281, 33, 0) $ASCII = GUICtrlCreateTabitem("ASCII") $browse_ASCII = GUICtrlCreateButton("&Browse", 328, 32, 121, 33, 0) GUICtrlCreateGroup("Characters Size:", 328, 72, 257, 50) $char_size_ASCII = GUICtrlCreateCombo("Smallest", 336, 92, 100, 25) GUICtrlSetData(-1,"Small|Normal|Large|Largest","Small") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("Font/Background color:", 328, 130, 257, 120) $Label7_ASCII = GUICtrlCreateLabel("Font color:",336, 150, 193, 25) $font_color_ASCII = GUICtrlCreateCombo("BLACK", 336, 168, 193, 25) GUICtrlSetData(-1,"WHITE","WHITE") $Label7_ASCII = GUICtrlCreateLabel("Background:",336, 197, 193, 25) $bg_color_ASCII = GUICtrlCreateCombo("BLACK", 336, 215, 193, 25) GUICtrlSetData(-1,"WHITE","BLACK") GUICtrlCreateGroup("", -99, -99, 1, 1) $invert = GUICtrlCreateCheckbox ("Invert", 336, 260, 120, 20) $ok_button_ASCII = GUICtrlCreateButton("&Convert", 328, 312, 281, 33, 0) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $browse $file = FileOpenDialog("test",@MyDocumentsDir,"images (*.jpg;*.gif)") $aInfo_test = _ImageGetInfo($file) GUICtrlSetData($width_test, _ImageGetParam($aInfo_test, "Width")) GUICtrlSetData($height_test, _ImageGetParam($aInfo_test, "Height")) Guictrlsetdata($file_size, int(FileGetSize($file)/1000)) GUICtrlSetImage($picca,$file) GUICtrlSetState($slider_procent,$GUI_ENABLE) GUICtrlSetData($slider_procent,25) case $msg = $browse_ASCII $file = FileOpenDialog("test",@MyDocumentsDir,"images (*.jpg;*.gif)") $aInfo_test = _ImageGetInfo($file) GUICtrlSetData($width_test, _ImageGetParam($aInfo_test, "Width")) GUICtrlSetData($height_test,_ImageGetParam($aInfo_test, "Height")) Guictrlsetdata($file_size, int(FileGetSize($file)/1000)) GUICtrlSetImage($picca,$file) GUICtrlSetState($slider_procent,$GUI_ENABLE) GUICtrlSetData($slider_procent,25) Case $msg = $ok_button values() case $msg = $ok_button_ASCII values_ASCII() EndSelect $read_procent = GUICtrlRead($slider_procent) GUICtrlSetData($slider_procent_text,$read_procent) Sleep(25) WEnd func values() Local $calc_total = 0 $aInfo = _ImageGetInfo($file) $i_width = _ImageGetParam($aInfo, "Width") $i_height = _ImageGetParam($aInfo, "Height") $image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP,$WS_EX_TOPMOST) GUICtrlCreatePic($file,0,0,$i_width,$i_height) $pr_height = WinGetPos($image) $progress = Guicreate("Progress",130,60,-1,$pr_height[1]-65,$WS_POPUP,$WS_EX_TOPMOST) GUICtrlCreateLabel("Reading:",10,10,100,20) $pixel_atm = GUICtrlCreateLabel("",60,10,150,20) GUICtrlCreateLabel("/",90,10,100,20) $pixel_total = GUICtrlCreateLabel("",100,10,100,20) $progressbar = GUICtrlCreateProgress (15,30,100,20,$PBS_SMOOTH) $procent = GUICtrlCreateLabel("100",50,33,30,20) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlCreateLabel("%",70,33,30,20) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUISetState(@SW_hide,$main) GUISetState(@SW_Show,$image) GUISetState(@SW_Show,$progress) $waardes = GUICtrlRead($characters) $total = Int(StringLen($waardes)) $info = WinGetPos($image) $read_procent = GUICtrlRead($slider_procent) $value = 100 / $read_procent $procent_pixels = Round($value) if $procent_pixels = 1 Then $procent_pixels = 2 EndIf $pixel_total_width = GUICtrlRead($width_test) $pixel_total_height = GUICtrlRead($height_test) $calc_1 = round($pixel_total_width/($procent_pixels-1)) $calc_2 = round($pixel_total_height/$procent_pixels) $calc_1_2 = $calc_1 * $calc_2 GUICtrlSetData($pixel_total,$calc_1_2) $value_progress = 100/$calc_1_2 $r_checked = GUICtrlRead($random) $l_checked = GuiCtrlRead($low) $c_checked = GUICtrlRead($color) $size_char = GUICtrlRead($char_size) Select case $size_char = "Smallest" $size = "-6" case $size_char = "Small" $size = "-3" case $size_char = "Normal" $size = "1" case $size_char = "Large" $size = "4" case $size_char = "Largest" $size = "6" EndSelect Select case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED $contrast_value = "<pre>" $contrast_value_end = "</pre>" convert_color_random() case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED $contrast_value = "" $contrast_value_end = "" convert_color_random() case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_CHECKED $contrast_value = "<pre>" $contrast_value_end = "</pre>" convert_color_Sequence() case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_CHECKED $contrast_value = "" $contrast_value_end = "" convert_color_Sequence() case $r_checked = $GUI_CHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED $contrast_value = "<pre>" $contrast_value_end = "</pre>" convert_grayscale_random() case $r_checked = $GUI_CHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED $contrast_value = "" $contrast_value_end = "" convert_grayscale_random() case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_CHECKED and $c_checked = $GUI_UNCHECKED $contrast_value = "<pre>" $contrast_value_end = "</pre>" convert_grayscale_Sequence() case $r_checked = $GUI_UNCHECKED and $l_checked = $GUI_UNCHECKED and $c_checked = $GUI_UNCHECKED $contrast_value = "" $contrast_value_end = "" convert_grayscale_Sequence() EndSelect EndFunc Func values_ASCII() Local $calc_total = 0 $aInfo = _ImageGetInfo($file) $i_width = _ImageGetParam($aInfo, "Width") $i_height = _ImageGetParam($aInfo, "Height") $image = GUICreate("",$i_width,$i_height,-1,-1,$WS_POPUP,$WS_EX_TOPMOST) GUICtrlCreatePic($file,0,0,$i_width,$i_height) $pr_height = WinGetPos($image) $progress = Guicreate("Progress",130,60,-1,$pr_height[1]-65,$WS_POPUP,$WS_EX_TOPMOST) GUICtrlCreateLabel("Reading:",10,10,100,20) $pixel_atm = GUICtrlCreateLabel("",60,10,150,20) GUICtrlCreateLabel("/",90,10,100,20) $pixel_total = GUICtrlCreateLabel("",100,10,100,20) $progressbar = GUICtrlCreateProgress (15,30,100,20,$PBS_SMOOTH) $procent = GUICtrlCreateLabel("100",50,33,30,20) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlCreateLabel("%",70,33,30,20) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUISetState(@SW_hide,$main) GUISetState(@SW_Show,$image) GUISetState(@SW_Show,$progress) $pixel_total_width = GUICtrlRead($width_test) $pixel_total_height = GUICtrlRead($height_test) $calc_1 = round($pixel_total_width/($procent_pixels-1)) $calc_2 = round($pixel_total_height/$procent_pixels) $calc_1_2 = $calc_1 * $calc_2 GUICtrlSetData($pixel_total,$calc_1_2) $value_progress = 100/$calc_1_2 $info = WinGetPos($image) $read_procent = GUICtrlRead($slider_procent) $value = 100 / $read_procent $procent_pixels = Round($value) if $procent_pixels = 1 Then $procent_pixels = 2 EndIf $pixel_total_width = GUICtrlRead($width_test) $pixel_total_height = GUICtrlRead($height_test) $calc_1 = round($pixel_total_width/($procent_pixels-1)) $calc_2 = round($pixel_total_height/$procent_pixels) $calc_1_2 = $calc_1 * $calc_2 GUICtrlSetData($pixel_total,$calc_1_2) $value_progress = 100/$calc_1_2 $font_color = GUICtrlRead($font_color_ASCII) $bg_color = GUICtrlRead($bg_color_ASCII) $size_char = GUICtrlRead($char_size_ASCII) Select case $size_char = "Smallest" $size_ASCII = "-6" case $size_char = "Small" $size_ASCII = "-3" case $size_char = "Normal" $size_ASCII = "1" case $size_char = "Large" $size_ASCII = "4" case $size_char = "Largest" $size_ASCII = "6" EndSelect if GUICtrlRead($invert) = 1 Then convert_ASCII_invert() Else convert_ASCII() EndIf EndFunc Func convert_color_random() Local $pixel $begin = TimerInit() FileDelete(@ScriptDir & "\html.htm") FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf) FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf) For $i = 1 to $i_height step +$procent_pixels For $x = 1 to $i_width step +($procent_pixels-1) $color = PixelGetColor($info[0] + $x , $info[1] + $i) $char = Random(1,$total+1) FileWrite(@ScriptDir & "\html.htm",'<font color="#' & Hex($color,6) & '">' & StringMid($waardes,$char,1) & "</font>") $pixel = $pixel + 1 GUICtrlSetData($pixel_atm,$pixel) $progress_count = $progress_count + $value_progress $progress_count_rounded = Round($progress_count) GUICtrlSetData($progressbar,$progress_count_rounded) GUICtrlSetData($procent,$progress_count_rounded) Next FileWrite(@ScriptDir & "\html.htm","<br>") Next GUISetState(@SW_HIDE,$image) FileWrite(@ScriptDir & "\html.htm",$contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf) $dif = TimerDiff($begin) Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>") ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open") GUISetState(@SW_HIDE,$progress) Exit EndFunc Func convert_color_Sequence() Local $pixel $begin = TimerInit() FileDelete(@ScriptDir & "\html.htm") FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf) FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf) For $i = 1 to $i_height step +$procent_pixels For $x = 1 to $i_width step +($procent_pixels-1) $color = PixelGetColor($info[0] + $x , $info[1] + $i) $show = $waardes FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $color & '">' & $show & "</font>") $pixel = $pixel + 1 GUICtrlSetData($pixel_atm,$pixel) $progress_count = $progress_count + $value_progress $progress_count_rounded = Round($progress_count) GUICtrlSetData($progressbar,$progress_count_rounded) GUICtrlSetData($procent,$progress_count_rounded) Next FileWrite(@ScriptDir & "\html.htm","<br>") Next GUISetState(@SW_HIDE,$image) FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf) $dif = TimerDiff($begin) Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>") ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open") GUISetState(@SW_HIDE,$progress) Exit EndFunc Func convert_grayscale_random() Local $pixel $begin = TimerInit() FileDelete(@ScriptDir & "\html.htm") FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf) FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf) For $i = 1 to $i_height step +$procent_pixels For $x = 1 to $i_width step +($procent_pixels-1) $color = PixelGetColor($info[0] + $x , $info[1] + $i) $char = Random(1,$total+1) $var = Hex($color, 6) $gray_1 = int(dec(StringLeft($var,2))*0.3) $gray_2 = int(dec(StringMid($var,3,2))*0.59) $gray_3 = int(dec(StringRight($var,2))*0.11) $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1) FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & StringMid($waardes,$char,1) & "</font>") $pixel = $pixel + 1 GUICtrlSetData($pixel_atm,$pixel) $progress_count = $progress_count + $value_progress $progress_count_rounded = Round($progress_count) GUICtrlSetData($progressbar,$progress_count_rounded) GUICtrlSetData($procent,$progress_count_rounded) Next FileWrite(@ScriptDir & "\html.htm","<br>") Next GUISetState(@SW_HIDE,$image) FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @CRLF) $dif = TimerDiff($begin) Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>") ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open") GUISetState(@SW_HIDE,$progress) Exit EndFunc Func convert_grayscale_Sequence() Local $pixel $begin = TimerInit() FileDelete(@ScriptDir & "\html.htm") FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf) FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf & '<table width="70%"><tr><td> <table align="center" cellpadding="10"> <tr bgcolor="' & GUICtrlRead($bg_color) & '"> <td> <font size="' & $size & '">' & $contrast_value & @crlf) For $i = 1 to $i_height step +$procent_pixels For $x = 1 to $i_width step +($procent_pixels-1) $color = PixelGetColor($info[0] + $x , $info[1] + $i) $show = $waardes $var = Hex($color, 6) $gray_1 = int(dec(StringLeft($var,2))*0.3) $gray_2 = int(dec(StringMid($var,3,2))*0.59) $gray_3 = int(dec(StringRight($var,2))*0.11) $grayscale = StringSplit(hex($gray_1 + $gray_2 + $gray_3),"000000",1) FileWrite(@ScriptDir & "\html.htm",'<font color="#' & $grayscale[2] & $grayscale[2] & $grayscale[2] & '">' & $show & "</font>") $pixel = $pixel + 1 GUICtrlSetData($pixel_atm,$pixel) $progress_count = $progress_count + $value_progress $progress_count_rounded = Round($progress_count) GUICtrlSetData($progressbar,$progress_count_rounded) GUICtrlSetData($procent,$progress_count_rounded) Next FileWrite(@ScriptDir & "\html.htm","<br>") Next GUISetState(@SW_HIDE,$image) FileWrite(@ScriptDir & "\html.htm", $contrast_value_end & @crlf & "</font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf) $dif = TimerDiff($begin) Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>") ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open") GUISetState(@SW_HIDE,$progress) Exit EndFunc func convert_ASCII() Local $pixel $begin = TimerInit() Dim $replace_characters[17] $replace_characters[0] = "#" $replace_characters[1] = "W" $replace_characters[2] = "M" $replace_characters[3] = "B" $replace_characters[4] = "R" $replace_characters[5] = "X" $replace_characters[6] = "V" $replace_characters[7] = "Y" $replace_characters[8] = "I" $replace_characters[9] = "t" $replace_characters[10] = "i" $replace_characters[11] = "+" $replace_characters[12] = "=" $replace_characters[13] = ";" $replace_characters[14] = ":" $replace_characters[15] = "," $replace_characters[16] = "." FileDelete(@ScriptDir & "\html.htm") FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf) FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf &'<table width="80%"><tr><td> <table align="center" cellpadding="10" > <tr bgcolor="' & $bg_color & '"> <td> <font color="' & $font_color & '" size="' & $size_ASCII & '"><pre>' &@crlf) For $i = 1 to $i_height step +$procent_pixels For $x = 1 to $i_width step +($procent_pixels-1) $color = PixelGetColor($info[0] + $x , $info[1] +$i) $var = Hex($color, 6) $gray_1 = dec(StringLeft($var,2)) $gray_2 = dec(StringMid($var,3,2)) $gray_3 = dec(StringRight($var,2)) $brightness = $gray_1+$gray_2+$gray_3 $replace_character_id = Round($brightness/50) +1 FileWrite(@ScriptDir & "\html.htm",$replace_characters[$replace_character_id]) $pixel = $pixel + 1 GUICtrlSetData($pixel_atm,$pixel) $progress_count = $progress_count + $value_progress $progress_count_rounded = Round($progress_count) GUICtrlSetData($progressbar,$progress_count_rounded) GUICtrlSetData($procent,$progress_count_rounded) Next FileWrite(@ScriptDir & "\html.htm",@CRLF) Next GUISetState(@SW_HIDE,$image) FileWrite(@ScriptDir & "\html.htm", "</pre></font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf) $dif = TimerDiff($begin) Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>") ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open") Exit EndFunc func convert_ASCII_invert() Local $pixel $begin = TimerInit() Dim $replace_characters[17] $replace_characters[0] = "." $replace_characters[1] = "," $replace_characters[2] = ":" $replace_characters[3] = ";" $replace_characters[4] = "=" $replace_characters[5] = "+" $replace_characters[6] = "i" $replace_characters[7] = "t" $replace_characters[8] = "I" $replace_characters[9] = "Y" $replace_characters[10] = "V" $replace_characters[11] = "X" $replace_characters[12] = "R" $replace_characters[13] = "B" $replace_characters[14] = "M" $replace_characters[15] = "W" $replace_characters[16] = "#" FileDelete(@ScriptDir & "\html.htm") FileWrite(@ScriptDir & "\html.htm","<html>" & @crlf) FileWrite(@ScriptDir & "\html.htm","<body>" & @crlf &'<table width="80%"><tr><td> <table align="center" cellpadding="10" > <tr bgcolor="' & $bg_color & '"> <td> <font color="' & $font_color & '" size="' & $size_ASCII & '"><pre>' &@crlf) For $i = 1 to $i_height step +$procent_pixels For $x = 1 to $i_width step +($procent_pixels-1) $color = PixelGetColor($info[0] + $x , $info[1] +$i) $var = Hex($color, 6) $gray_1 = dec(StringLeft($var,2)) $gray_2 = dec(StringMid($var,3,2)) $gray_3 = dec(StringRight($var,2)) $brightness = $gray_1+$gray_2+$gray_3 $replace_character_id = Round($brightness/50) +1 FileWrite(@ScriptDir & "\html.htm",$replace_characters[$replace_character_id]) $pixel = $pixel + 1 GUICtrlSetData($pixel_atm,$pixel) $progress_count = $progress_count + $value_progress $progress_count_rounded = Round($progress_count) GUICtrlSetData($progressbar,$progress_count_rounded) GUICtrlSetData($procent,$progress_count_rounded) Next FileWrite(@ScriptDir & "\html.htm",@CRLF) Next GUISetState(@SW_HIDE,$image) FileWrite(@ScriptDir & "\html.htm", "</pre></font>" & @crlf & "</td></tr></table></td></tr></table>" & @crlf) $dif = TimerDiff($begin) Filewrite(@scriptdir & "\html.htm", @crlf & '<font face="arial"> Time took to convert: <b>' & int($dif/1000) & "</b> sec.</font>" & @crlf & "</body>" & @crlf & "</html>") ShellExecute(@ScriptDir & "\html.htm", "", @ScriptDir, "open") Exit EndFunc Enjoy AutoIt... GreenCan Contributions CheckUpdate - SelfUpdating script ------- Self updating script Dynamic input validation ------------------- Use a Input masks can make your life easier and Validation can be as simple MsgBox with CountDown ------------------- MsgBox with visual countdown Display Multiline text cells in ListView ---- Example of pop-up or ToolTip for multiline text items in ListView Presentation Manager ---------------------- Program to display and refresh different Border-less GUI's on a Display (large screen TV) USB Drive Tools ------------------------------ Tool to help you with your USB drive management Input Period udf ------------------------------ GUI for a period input Excel ColorPicker ---------------------------- Color pickup tool will allow you to select a color from the standard Excel color palette Excel Chart UDF ----------------------------- Collaboration project with water GetDateInString ------------------------------ Find date/time in a string using a date format notation like DD Mon YYYY hh:mm TaskListAllDetailed --------------------------- List All Scheduled Tasks Computer Info --------------------------------- A collection of information for helpdesk Shared memory Demo ----------------------- Demo: Two applications communicate with each other through means of a memory share (using Nomad function, 32bit only) Universal Date Format Conversion -------- Universal date converter from your PC local date format to any format Disable Windows DetailsPane -------------- Disable Windows Explorer Details Pane Oracle SQL Report Generator ------------- Oracle Report generator using SQL SQLite Report Generator ------------------- SQLite Report generator using SQL SQLite ListView and BLOB demo ---------- Demo: shows how binary (image) objects can be recognized natively in a database BLOB field DSN-Less Database connection demo --- Demo: ActiveX Data Objects DSN-Less Database access Animated animals ----------------------------- Fun: Moving animated objects Perforated image in GUI --------------------- Fun: Perforate your image with image objects UEZ's Perforator major update ------------- Fun: Pro version of Perforator by UEZ Visual Crop Tool (GUI) ----------------------- Easy to use Visual Image Crop tool Visual Image effect (GUI) -------------------- Visually apply effects on an image 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