Jump to content

True ascii converter


magician13134
 Share

Recommended Posts

So I was browsing the forums the other day and came across an image to text converter (by.. NeoFoX?), and it's pretty cool, but I was slightly dissapointed that it didn't do true ascii (no color, all characters), so I decided to write my own... So let me know what you think. And true ascii is a little... not perfect because of my character selection, so if you have a better set of characters, I'd love to have them...

# & $ + @ & ; * = ~ - : ^ ' `

0 1 2 3 4 5 6 7 8 9 a b c d e f

It also does color and greyscale text-images...

(fixed a minor bug, reuploaded new version)

I included a couple I did of Reel Big Fish and some of the members

post-18326-1169232902_thumb.png

post-18326-1169232910_thumb.png

ascii.exe

Edited by magician13134
Link to comment
Share on other sites

Likewise... looks like a great concept, but there is no way I am running an .exe without seeing the source.

I'm sorry. My bad.

#include <GUIConstants.au3>
#include "image_get_info.au3"
;#include <IE.au3> I don't think you need this... I forget why it's here. If you get bugs, try uncommenting it and let me know...
Opt("TrayMenuMode",1)
TraySetToolTip("MSI - Image to Ascii converter")
$TrayAd = TrayCreateItem("www.magicsoftinc.com")
TrayCreateItem("")
$TrayClose = TrayCreateItem("Close")
$output = @ScriptDir
$GUI = GUICreate("Magic Soft Inc. - Image to Ascii Converter", 350, 210)
$FileLocationCtrl = GUICtrlCreateInput("", 5, 5, 235)
$OpenButton = GUICtrlCreateButton("Choose a file", 245, 3, 95, 25)
$SkipCtrl = GUICtrlCreateSlider(5, 30, 340)
GUICtrlSetLimit($SkipCtrl, 100, 1)
GUICtrlSetData($SkipCtrl, 33)
$pixels = GUICtrlCreateLabel("", 95, 67, 300)
$ColorCtrl = GUICtrlCreateRadio("Color", 5, 60, 45)
$GreyCtrl = GUICtrlCreateRadio("Greyscale", 5, 80, 70)
$TrueCtrl = GUICtrlCreateRadio("True Ascii", 5, 100, 85)
GUICtrlSetState ($ColorCtrl, $GUI_CHECKED)
GUICtrlCreateLabel("BG:", 115, 99)
$bgCtrl = GUICtrlCreateInput("#000000", 135, 95, 55)
GUICtrlSetLimit($bgCtrl, 7)
GUICtrlSetData($pixels, "Will render " & GUICtrlRead($SkipCtrl) & "% of the image pixels")
$start = GUICtrlCreateButton("Start", 300, 92, 45)
$ChangeOut = GUICtrlCreateButton("Change output", 205, 92, 85)
$PatternCtrl = GUICtrlCreateInput("", 5, 125, 340, 19)
GUICtrlCreateLabel("Enter text to use, or leave blank for random. (No spaces, use - instead)", 5, 148)
$FontSize = GUICtrlCreateSlider(5, 168, 340, 20)
GUICtrlSetLimit($FontSize, 7, 1)
GUICtrlSetData($FontSize, 1)
$FontLabel = GUICtrlCreateLabel("Font size: 1", 140, 190)
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $SkipCtrl Then GUICtrlSetData($pixels, "Will render " & GUICtrlRead($SkipCtrl) & "% of the image pixels")
    If $msg = $FontSize Then GUICtrlSetData($FontLabel, "Font size: " & GUICtrlRead($FontSize))
    If $msg = $OpenButton Then
        $open = FileOpenDialog("Select a picture", @MyDocumentsDir, "Pictures (*.bmp; *.gif; *.jpg; *.tif; *.tiff; *jpeg)")
        If $open <> "" Then GUICtrlSetData($FileLocationCtrl, $open)
    EndIf
    If TrayGetMsg() = $TrayClose Then Exit
    If TrayGetMsg() = $TrayAd Then _IECreate ("www.magicsoftinc.com/")
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $TrueCtrl Then 
        GUICtrlSetState($bgCtrl, $GUI_DISABLE)
        MsgBox(0, "Magic Soft Inc.", "Please note that true ascii is currently beta and may not look" & @LF & _
                    "as good as the other options. Also, ascii is character based, causing it to word wrap," & @LF & _
                    "which will make your picture not work if it is larger than your screen.")
    EndIf
    If $msg = $GreyCtrl or $msg = $ColorCtrl Then GUICtrlSetState($bgCtrl, $GUI_ENABLE)
    If $msg = $start Then
        If Not FileExists(GUICtrlRead($FileLocationCtrl)) Then
            MsgBox(48, "Error", "Please select a valid image file first!")
        Else
            generate()
        EndIf
    EndIf
    If $msg = $ChangeOut Then
        $NewLocation = FileSelectFolder("Choose an output location", "", 5, $output)
        If $NewLocation <> "" Then $output = $NewLocation
    EndIf
WEnd
Func generate()
    If GUICtrlRead($TrueCtrl) = 1 Then
        TrueAscii()
    Else
        If GUICtrlRead($GreyCtrl) = 1 Then $grey = 1
        If GuiCtrlRead($ColorCtrl) = 1 Then $grey = 0
        $FileLocation = GUICtrlRead($FileLocationCtrl)
        $aInfo = _ImageGetInfo($FileLocation)
        $width = _ImageGetParam($aInfo, "Width")
        $height =  _ImageGetParam($aInfo, "Height")
        If $width*$height>35000 Then
            $ResizeAmount = InputBox("Large image!", "Large images can take a LONG time to load, and won't even look good. What do you want the width to be?" & _
                                    @LF & @LF & "Currently:" & $width & "x" & $height, 200)
            If $ResizeAmount = "" Then $ResizeAmount = 200
            $height = $height/($width/$ResizeAmount)
            $width = $width/($width/$ResizeAmount)
        EndIf
        If Not @error Then
            $size = GUICtrlRead($FontSize)
            $bg = GUICtrlRead($bgCtrl)
            $skip = int(GUICtrlRead($SkipCtrl))
            $destination = 100/$skip
            $pattern = GUICtrlRead($PatternCtrl)
            GUISetState(@SW_HIDE, $GUI)
            $progressGUI = GUICreate("Progress...", 410, 30)
            $progress = GUICtrlCreateProgress(5, 5, 400, 20, $PBS_SMOOTH)
            GUICtrlSetData($progress, 0)
            WinSetTrans("Progress...", "", 128)
            WinSetOnTop("Progress...", "", 1)
            GUISetState()
            For $i = 1 to 10000
                If Not FileExists($output & "\MSI Ascii #" & $i & ".html") Then ExitLoop
            Next
            SplashImageOn("", $FileLocation, $width, $height, 0, 0, 1)
            FileWrite($output & "\MSI Ascii #" & $i & ".html", "<title>www.magicsoftinc.com - Ascii Converter</title><body bgcolor=" & $bg & _
                                "><font face='courier new' size=" & $size & ">")
            If $pattern = "" Then ;Numbers
                $ProgressSet=0
                For $y = 1 to $height step $destination
                    $ProgressSet+=(100/$height)*$destination
                    GUICtrlSetData($progress, $ProgressSet)
                    For $x = 1 to $width step $destination
                        $z = Hex(PixelGetColor($x, $y), 6)
                        If $grey Then
                            $grey_1 = int(dec(StringLeft($z,2))*0.3)
                            $grey_2 = int(dec(StringMid($z,3,2))*0.59)
                            $grey_3 = int(dec(StringRight($z,2))*0.11)
                            $greyscale = StringSplit(hex($grey_1 + $grey_2 + $grey_3),"000000",1)
                            $z = $greyscale[2] & $greyscale[2] & $greyscale[2]
                        EndIf
                        FileWrite($output & "\MSI Ascii #" & $i & ".html", "<font color=#" & $z & ">"& Floor(Random(10, 99)))           
                    Next
                    FileWrite($output & "\MSI Ascii #" & $i & ".html", "<br>")
                Next
            Else ;Text
                $j = 1
                $pattern = StringSplit($pattern, "")
                $max = $pattern[0]
                $ProgressSet=0
                For $y = 1 to $height step $destination
                    $ProgressSet+=(100/$height)*$destination
                    GUICtrlSetData($progress, $ProgressSet)
                        For $x = 1 to $width step $destination
                            $z = Hex(PixelGetColor($x, $y), 6)
                            If $grey Then
                                $grey_1 = int(dec(StringLeft($z,2))*0.3)
                                $grey_2 = int(dec(StringMid($z,3,2))*0.59)
                                $grey_3 = int(dec(StringRight($z,2))*0.11)
                                $greyscale = StringSplit(hex($grey_1 + $grey_2 + $grey_3),"000000",1)
                                $z = $greyscale[2] & $greyscale[2] & $greyscale[2]
                            EndIf
                            FileWrite($output & "\MSI Ascii #" & $i & ".html", "<font color=#" & $z & ">"& $pattern[$j])
                            If $j = $max Then
                                $j = 1
                            Else
                                $j+=1
                            EndIf
                            FileWrite($output & "\MSI Ascii #" & $i & ".html", $pattern[$j])        
                            If $j = $max Then
                                $j = 1
                            Else
                                $j+=1
                            EndIf
                        Next
                        FileWrite($output & "\MSI Ascii #" & $i & ".html", "<br>")
                Next
            EndIf
            FileWrite($output & "\MSI Ascii #" & $i & ".html", "</font></body><!--Ascii converter by Magic Soft Inc. (www.magicsoftinc.com)-->")
            SplashOff()
            GUIDelete($progressGUI)
            GUISetState(@SW_SHOW, $GUI)
            FileSetAttrib($output & "\MSI Ascii #" & $i & ".html", "+R")
            MsgBox(48, "www.MagicSoftInc.com", "Your image has been successfully converted to Ascii thanks to" & @LF & _
                        "Magic Soft Inc.'s image to Ascii Converter!")
        EndIf
    EndIf
EndFunc
Func TrueAscii()
    $FileLocation = GUICtrlRead($FileLocationCtrl)
    $aInfo = _ImageGetInfo($FileLocation)
    $width = _ImageGetParam($aInfo, "Width")
    $height =  _ImageGetParam($aInfo, "Height")
    If $width*$height>35000 Then
        $ResizeAmount = InputBox("Large image!", "Large images can take a LONG time, and won't even look good. What do you want the width to be?" & _
                                @LF & @LF & "Currently:" & $width & "x" & $height, 100)
        If $ResizeAmount = "" Then $ResizeAmount = 200
        $height = $height/($width/$ResizeAmount)
        $width = $width/($width/$ResizeAmount)
    EndIf
    If Not @Error Then
        $size = GUICtrlRead($FontSize)
        $bg = "#FFFFFF"
        $skip = int(GUICtrlRead($SkipCtrl))
        $destination = 100/$skip
        GUISetState(@SW_HIDE, $GUI)
        $progressGUI = GUICreate("Progress...", 410, 30)
        WinSetTrans("Progress...", "", 128)
        WinSetOnTop("Progress...", "", 1)
        $progress = GUICtrlCreateProgress(5, 5, 400, 20, $PBS_SMOOTH)
        GUICtrlSetData($progress, 0)
        GUISetState()
        For $i = 1 to 10000
            If Not FileExists($output & "\MSI Ascii #" & $i & ".html") Then ExitLoop
        Next
        SplashImageOn("", $FileLocation, $width, $height, 0, 0, 1)
        FileWrite($output & "\MSI Ascii #" & $i & ".html", "<title>www.magicsoftinc.com - Ascii Converter</title><body bgcolor=" & $bg & _
                            "><font face='courier new' size=" & $size & ">")
        $ProgressSet=0
        For $y = 1 to $height step $destination
            $ProgressSet+=(100/$height)*$destination
            GUICtrlSetData($progress, $ProgressSet)
            For $x = 1 to $width step $destination
                $z = Hex(PixelGetColor($x, $y), 6)
                $grey_1 = int(dec(StringLeft($z,2))*0.3)
                $grey_2 = int(dec(StringMid($z,3,2))*0.59)
                $grey_3 = int(dec(StringRight($z,2))*0.11)
                $greyscale = StringSplit(hex($grey_1 + $grey_2 + $grey_3),"000000",1)
                $z = $greyscale[2] & $greyscale[2] & $greyscale[2]
                $z = StringSplit($z, "")
                If $z[1] = "0" Then $z[1] = "#";First Pixel
                If $z[1] = "1" Then $z[1] = "%"
                If $z[1] = "2" Then $z[1] = "$"
                If $z[1] = "3" Then $z[1] = "+"
                If $z[1] = "4" Then $z[1] = "@"
                If $z[1] = "5" Then $z[1] = "&"
                If $z[1] = "6" Then $z[1] = ";"
                If $z[1] = "7" Then $z[1] = "*"
                If $z[1] = "8" Then $z[1] = "="
                If $z[1] = "9" Then $z[1] = "~"
                If $z[1] = "A" Then $z[1] = "-"
                If $z[1] = "B" Then $z[1] = ":"
                If $z[1] = "C" Then $z[1] = "^"
                If $z[1] = "D" Then $z[1] = "'"
                If $z[1] = "E" Then $z[1] = "`"
                If $z[1] = "F" Then $z[1] = " "
                If $z[2] = "0" Then $z[2] = "#";Second Pixel
                If $z[2] = "1" Then $z[2] = "$"
                If $z[2] = "2" Then $z[2] = "+"
                If $z[2] = "3" Then $z[2] = "@"
                If $z[2] = "4" Then $z[2] = "&"
                If $z[2] = "5" Then $z[2] = ";"
                If $z[2] = "6" Then $z[2] = "*"
                If $z[2] = "7" Then $z[2] = "="
                If $z[2] = "8" Then $z[2] = "~"
                If $z[2] = "9" Then $z[2] = "-"
                If $z[2] = "A" Then $z[2] = ":"
                If $z[2] = "B" Then $z[2] = "^"
                If $z[2] = "C" Then $z[2] = "'"
                If $z[2] = "D" Then $z[2] = "`"
                If $z[2] = "E" Then $z[2] = " "
                $z = $z[1] & $z[2]
                FileWrite($output & "\MSI Ascii #" & $i & ".html", $z)          
            Next
            FileWrite($output & "\MSI Ascii #" & $i & ".html", "<br>")
        Next
        FileWrite($output & "\MSI Ascii #" & $i & ".html", "</font></body><!--Ascii converter by Magic Soft Inc. (www.magicsoftinc.com)-->")
        SplashOff()
        GUIDelete($progressGUI)
        GUISetState(@SW_SHOW, $GUI)
        FileSetAttrib($output & "\MSI Ascii #" & $i & ".html", "+R")
        MsgBox(48, "www.MagicSoftInc.com", "Your image has been successfully converted to Ascii thanks to" & @LF & _
                    "Magic Soft Inc.'s image to Ascii Converter!")
        EndIf
EndFunc

Please note, I wrote ALL of this from scratch except the three lines where it converts to greyscale

Edited by magician13134
Link to comment
Share on other sites

Can you also include - #include "image_get_info.au3"

I'm sorry. My bad.

#include <GUIConstants.au3>
#include "image_get_info.au3"
;#include <IE.au3> I don't think you need this... I forget why it's here. If you get bugs, try uncommenting it and let me know...
Opt("TrayMenuMode",1)
TraySetToolTip("MSI - Image to Ascii converter")
$TrayAd = TrayCreateItem("www.magicsoftinc.com")
TrayCreateItem("")
$TrayClose = TrayCreateItem("Close")
$output = @ScriptDir
$GUI = GUICreate("Magic Soft Inc. - Image to Ascii Converter", 350, 210)
$FileLocationCtrl = GUICtrlCreateInput("", 5, 5, 235)
$OpenButton = GUICtrlCreateButton("Choose a file", 245, 3, 95, 25)
$SkipCtrl = GUICtrlCreateSlider(5, 30, 340)
GUICtrlSetLimit($SkipCtrl, 100, 1)
GUICtrlSetData($SkipCtrl, 33)
$pixels = GUICtrlCreateLabel("", 95, 67, 300)
$ColorCtrl = GUICtrlCreateRadio("Color", 5, 60, 45)
$GreyCtrl = GUICtrlCreateRadio("Greyscale", 5, 80, 70)
$TrueCtrl = GUICtrlCreateRadio("True Ascii", 5, 100, 85)
GUICtrlSetState ($ColorCtrl, $GUI_CHECKED)
GUICtrlCreateLabel("BG:", 115, 99)
$bgCtrl = GUICtrlCreateInput("#000000", 135, 95, 55)
GUICtrlSetLimit($bgCtrl, 7)
GUICtrlSetData($pixels, "Will render " & GUICtrlRead($SkipCtrl) & "% of the image pixels")
$start = GUICtrlCreateButton("Start", 300, 92, 45)
$ChangeOut = GUICtrlCreateButton("Change output", 205, 92, 85)
$PatternCtrl = GUICtrlCreateInput("", 5, 125, 340, 19)
GUICtrlCreateLabel("Enter text to use, or leave blank for random. (No spaces, use - instead)", 5, 148)
$FontSize = GUICtrlCreateSlider(5, 168, 340, 20)
GUICtrlSetLimit($FontSize, 7, 1)
GUICtrlSetData($FontSize, 1)
$FontLabel = GUICtrlCreateLabel("Font size: 1", 140, 190)
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $SkipCtrl Then GUICtrlSetData($pixels, "Will render " & GUICtrlRead($SkipCtrl) & "% of the image pixels")
    If $msg = $FontSize Then GUICtrlSetData($FontLabel, "Font size: " & GUICtrlRead($FontSize))
    If $msg = $OpenButton Then
        $open = FileOpenDialog("Select a picture", @MyDocumentsDir, "Pictures (*.bmp; *.gif; *.jpg; *.tif; *.tiff; *jpeg)")
        If $open <> "" Then GUICtrlSetData($FileLocationCtrl, $open)
    EndIf
    If TrayGetMsg() = $TrayClose Then Exit
    If TrayGetMsg() = $TrayAd Then _IECreate ("www.magicsoftinc.com/")
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $TrueCtrl Then 
        GUICtrlSetState($bgCtrl, $GUI_DISABLE)
        MsgBox(0, "Magic Soft Inc.", "Please note that true ascii is currently beta and may not look" & @LF & _
                    "as good as the other options. Also, ascii is character based, causing it to word wrap," & @LF & _
                    "which will make your picture not work if it is larger than your screen.")
    EndIf
    If $msg = $GreyCtrl or $msg = $ColorCtrl Then GUICtrlSetState($bgCtrl, $GUI_ENABLE)
    If $msg = $start Then
        If Not FileExists(GUICtrlRead($FileLocationCtrl)) Then
            MsgBox(48, "Error", "Please select a valid image file first!")
        Else
            generate()
        EndIf
    EndIf
    If $msg = $ChangeOut Then
        $NewLocation = FileSelectFolder("Choose an output location", "", 5, $output)
        If $NewLocation <> "" Then $output = $NewLocation
    EndIf
WEnd
Func generate()
    If GUICtrlRead($TrueCtrl) = 1 Then
        TrueAscii()
    Else
        If GUICtrlRead($GreyCtrl) = 1 Then $grey = 1
        If GuiCtrlRead($ColorCtrl) = 1 Then $grey = 0
        $FileLocation = GUICtrlRead($FileLocationCtrl)
        $aInfo = _ImageGetInfo($FileLocation)
        $width = _ImageGetParam($aInfo, "Width")
        $height =  _ImageGetParam($aInfo, "Height")
        If $width*$height>35000 Then
            $ResizeAmount = InputBox("Large image!", "Large images can take a LONG time to load, and won't even look good. What do you want the width to be?" & _
                                    @LF & @LF & "Currently:" & $width & "x" & $height, 200)
            If $ResizeAmount = "" Then $ResizeAmount = 200
            $height = $height/($width/$ResizeAmount)
            $width = $width/($width/$ResizeAmount)
        EndIf
        If Not @error Then
            $size = GUICtrlRead($FontSize)
            $bg = GUICtrlRead($bgCtrl)
            $skip = int(GUICtrlRead($SkipCtrl))
            $destination = 100/$skip
            $pattern = GUICtrlRead($PatternCtrl)
            GUISetState(@SW_HIDE, $GUI)
            $progressGUI = GUICreate("Progress...", 410, 30)
            $progress = GUICtrlCreateProgress(5, 5, 400, 20, $PBS_SMOOTH)
            GUICtrlSetData($progress, 0)
            WinSetTrans("Progress...", "", 128)
            WinSetOnTop("Progress...", "", 1)
            GUISetState()
            For $i = 1 to 10000
                If Not FileExists($output & "\MSI Ascii #" & $i & ".html") Then ExitLoop
            Next
            SplashImageOn("", $FileLocation, $width, $height, 0, 0, 1)
            FileWrite($output & "\MSI Ascii #" & $i & ".html", "<title>www.magicsoftinc.com - Ascii Converter</title><body bgcolor=" & $bg & _
                                "><font face='courier new' size=" & $size & ">")
            If $pattern = "" Then ;Numbers
                $ProgressSet=0
                For $y = 1 to $height step $destination
                    $ProgressSet+=(100/$height)*$destination
                    GUICtrlSetData($progress, $ProgressSet)
                    For $x = 1 to $width step $destination
                        $z = Hex(PixelGetColor($x, $y), 6)
                        If $grey Then
                            $grey_1 = int(dec(StringLeft($z,2))*0.3)
                            $grey_2 = int(dec(StringMid($z,3,2))*0.59)
                            $grey_3 = int(dec(StringRight($z,2))*0.11)
                            $greyscale = StringSplit(hex($grey_1 + $grey_2 + $grey_3),"000000",1)
                            $z = $greyscale[2] & $greyscale[2] & $greyscale[2]
                        EndIf
                        FileWrite($output & "\MSI Ascii #" & $i & ".html", "<font color=#" & $z & ">"& Floor(Random(10, 99)))           
                    Next
                    FileWrite($output & "\MSI Ascii #" & $i & ".html", "<br>")
                Next
            Else ;Text
                $j = 1
                $pattern = StringSplit($pattern, "")
                $max = $pattern[0]
                $ProgressSet=0
                For $y = 1 to $height step $destination
                    $ProgressSet+=(100/$height)*$destination
                    GUICtrlSetData($progress, $ProgressSet)
                        For $x = 1 to $width step $destination
                            $z = Hex(PixelGetColor($x, $y), 6)
                            If $grey Then
                                $grey_1 = int(dec(StringLeft($z,2))*0.3)
                                $grey_2 = int(dec(StringMid($z,3,2))*0.59)
                                $grey_3 = int(dec(StringRight($z,2))*0.11)
                                $greyscale = StringSplit(hex($grey_1 + $grey_2 + $grey_3),"000000",1)
                                $z = $greyscale[2] & $greyscale[2] & $greyscale[2]
                            EndIf
                            FileWrite($output & "\MSI Ascii #" & $i & ".html", "<font color=#" & $z & ">"& $pattern[$j])
                            If $j = $max Then
                                $j = 1
                            Else
                                $j+=1
                            EndIf
                            FileWrite($output & "\MSI Ascii #" & $i & ".html", $pattern[$j])        
                            If $j = $max Then
                                $j = 1
                            Else
                                $j+=1
                            EndIf
                        Next
                        FileWrite($output & "\MSI Ascii #" & $i & ".html", "<br>")
                Next
            EndIf
            FileWrite($output & "\MSI Ascii #" & $i & ".html", "</font></body><!--Ascii converter by Magic Soft Inc. (www.magicsoftinc.com)-->")
            SplashOff()
            GUIDelete($progressGUI)
            GUISetState(@SW_SHOW, $GUI)
            FileSetAttrib($output & "\MSI Ascii #" & $i & ".html", "+R")
            MsgBox(48, "www.MagicSoftInc.com", "Your image has been successfully converted to Ascii thanks to" & @LF & _
                        "Magic Soft Inc.'s image to Ascii Converter!")
        EndIf
    EndIf
EndFunc
Func TrueAscii()
    $FileLocation = GUICtrlRead($FileLocationCtrl)
    $aInfo = _ImageGetInfo($FileLocation)
    $width = _ImageGetParam($aInfo, "Width")
    $height =  _ImageGetParam($aInfo, "Height")
    If $width*$height>35000 Then
        $ResizeAmount = InputBox("Large image!", "Large images can take a LONG time, and won't even look good. What do you want the width to be?" & _
                                @LF & @LF & "Currently:" & $width & "x" & $height, 100)
        If $ResizeAmount = "" Then $ResizeAmount = 200
        $height = $height/($width/$ResizeAmount)
        $width = $width/($width/$ResizeAmount)
    EndIf
    If Not @Error Then
        $size = GUICtrlRead($FontSize)
        $bg = "#FFFFFF"
        $skip = int(GUICtrlRead($SkipCtrl))
        $destination = 100/$skip
        GUISetState(@SW_HIDE, $GUI)
        $progressGUI = GUICreate("Progress...", 410, 30)
        WinSetTrans("Progress...", "", 128)
        WinSetOnTop("Progress...", "", 1)
        $progress = GUICtrlCreateProgress(5, 5, 400, 20, $PBS_SMOOTH)
        GUICtrlSetData($progress, 0)
        GUISetState()
        For $i = 1 to 10000
            If Not FileExists($output & "\MSI Ascii #" & $i & ".html") Then ExitLoop
        Next
        SplashImageOn("", $FileLocation, $width, $height, 0, 0, 1)
        FileWrite($output & "\MSI Ascii #" & $i & ".html", "<title>www.magicsoftinc.com - Ascii Converter</title><body bgcolor=" & $bg & _
                            "><font face='courier new' size=" & $size & ">")
        $ProgressSet=0
        For $y = 1 to $height step $destination
            $ProgressSet+=(100/$height)*$destination
            GUICtrlSetData($progress, $ProgressSet)
            For $x = 1 to $width step $destination
                $z = Hex(PixelGetColor($x, $y), 6)
                $grey_1 = int(dec(StringLeft($z,2))*0.3)
                $grey_2 = int(dec(StringMid($z,3,2))*0.59)
                $grey_3 = int(dec(StringRight($z,2))*0.11)
                $greyscale = StringSplit(hex($grey_1 + $grey_2 + $grey_3),"000000",1)
                $z = $greyscale[2] & $greyscale[2] & $greyscale[2]
                $z = StringSplit($z, "")
                If $z[1] = "0" Then $z[1] = "#";First Pixel
                If $z[1] = "1" Then $z[1] = "%"
                If $z[1] = "2" Then $z[1] = "$"
                If $z[1] = "3" Then $z[1] = "+"
                If $z[1] = "4" Then $z[1] = "@"
                If $z[1] = "5" Then $z[1] = "&"
                If $z[1] = "6" Then $z[1] = ";"
                If $z[1] = "7" Then $z[1] = "*"
                If $z[1] = "8" Then $z[1] = "="
                If $z[1] = "9" Then $z[1] = "~"
                If $z[1] = "A" Then $z[1] = "-"
                If $z[1] = "B" Then $z[1] = ":"
                If $z[1] = "C" Then $z[1] = "^"
                If $z[1] = "D" Then $z[1] = "'"
                If $z[1] = "E" Then $z[1] = "`"
                If $z[1] = "F" Then $z[1] = " "
                If $z[2] = "0" Then $z[2] = "#";Second Pixel
                If $z[2] = "1" Then $z[2] = "$"
                If $z[2] = "2" Then $z[2] = "+"
                If $z[2] = "3" Then $z[2] = "@"
                If $z[2] = "4" Then $z[2] = "&"
                If $z[2] = "5" Then $z[2] = ";"
                If $z[2] = "6" Then $z[2] = "*"
                If $z[2] = "7" Then $z[2] = "="
                If $z[2] = "8" Then $z[2] = "~"
                If $z[2] = "9" Then $z[2] = "-"
                If $z[2] = "A" Then $z[2] = ":"
                If $z[2] = "B" Then $z[2] = "^"
                If $z[2] = "C" Then $z[2] = "'"
                If $z[2] = "D" Then $z[2] = "`"
                If $z[2] = "E" Then $z[2] = " "
                $z = $z[1] & $z[2]
                FileWrite($output & "\MSI Ascii #" & $i & ".html", $z)          
            Next
            FileWrite($output & "\MSI Ascii #" & $i & ".html", "<br>")
        Next
        FileWrite($output & "\MSI Ascii #" & $i & ".html", "</font></body><!--Ascii converter by Magic Soft Inc. (www.magicsoftinc.com)-->")
        SplashOff()
        GUIDelete($progressGUI)
        GUISetState(@SW_SHOW, $GUI)
        FileSetAttrib($output & "\MSI Ascii #" & $i & ".html", "+R")
        MsgBox(48, "www.MagicSoftInc.com", "Your image has been successfully converted to Ascii thanks to" & @LF & _
                    "Magic Soft Inc.'s image to Ascii Converter!")
        EndIf
EndFunc

Please note, I wrote ALL of this from scratch except the three lines where it converts to greyscale

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

  • Moderators

I didn't go through the whole thing, but just a note, you could probably change:

If $z[1] = "0" Then $z[1] = "#";First Pixel
If $z[1] = "1" Then $z[1] = "%"
If $z[1] = "2" Then $z[1] = "$"
If $z[1] = "3" Then $z[1] = "+"
If $z[1] = "4" Then $z[1] = "@"
If $z[1] = "5" Then $z[1] = "&"
If $z[1] = "6" Then $z[1] = ";"
If $z[1] = "7" Then $z[1] = "*"
If $z[1] = "8" Then $z[1] = "="
If $z[1] = "9" Then $z[1] = "~"
If $z[1] = "A" Then $z[1] = "-"
If $z[1] = "B" Then $z[1] = ":"
If $z[1] = "C" Then $z[1] = "^"
If $z[1] = "D" Then $z[1] = "'"
If $z[1] = "E" Then $z[1] = "`"
If $z[1] = "F" Then $z[1] = " "
If $z[2] = "0" Then $z[2] = "#";Second Pixel
If $z[2] = "1" Then $z[2] = "$"
If $z[2] = "2" Then $z[2] = "+"
If $z[2] = "3" Then $z[2] = "@"
If $z[2] = "4" Then $z[2] = "&"
If $z[2] = "5" Then $z[2] = ";"
If $z[2] = "6" Then $z[2] = "*"
If $z[2] = "7" Then $z[2] = "="
If $z[2] = "8" Then $z[2] = "~"
If $z[2] = "9" Then $z[2] = "-"
If $z[2] = "A" Then $z[2] = ":"
If $z[2] = "B" Then $z[2] = "^"
If $z[2] = "C" Then $z[2] = "'"
If $z[2] = "D" Then $z[2] = "`"
If $z[2] = "E" Then $z[2] = " "oÝ÷ Ûð¨uàhÅ:ºÚ"µÍØØ[    ÌÍØVÚHÝ[ÔÜ]
    ÌÎNÌLÍ
MÎPPÑQÌÎNË ÌÎNÉÌÎNÊBØØ[    ÌÍØVÛÛHÝ[ÔÜ]
    ][ÝÈÉIÌÍÊÐ   [ÎÊ_NÌÎNÉÎMÈ ][ÝË  ÌÎNÉÌÎNÊBÜ   ÌÍÚPÐÈHHÈ ÌÍØVÚÌBRY  ÌÍÞÌWHH ÌÍØVÚÉÌÍÚPÐ×H[    ÌÍÞÌWHH ÌÍØVÛÛÉÌÍÚPÐ×BRY ÌÍÞÌHH  ÌÍØVÚÉÌÍÚPÐ×H[    ÌÍÞÌHH  ÌÍØVÛÛÉÌÍÚPÐ×B^

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...