Hallöchen ihr lieben,
ich habe gerade ein Problem:
Ich will einen einfachen, simplen Ascii Art Generator in meine Anwendung integrieren, ähnlich diesem.
Allerdings bekomme ich aus irgend einem Grund immer einen Overflow wenn ich eine Konvertierung durchführen möchte.
Der Fehler tritt bei
Spoiler anzeigen
Weiß jemand, woran das liegt und wie man das beheben kann?
ich habe gerade ein Problem:
Ich will einen einfachen, simplen Ascii Art Generator in meine Anwendung integrieren, ähnlich diesem.
Allerdings bekomme ich aus irgend einem Grund immer einen Overflow wenn ich eine Konvertierung durchführen möchte.
Der Fehler tritt bei
Dim red As Integer = CInt((pixelColor.R + pixelColor.G + pixelColor.B) / 3)
aufVB.NET-Quellcode
- Private Function ConvertToAscii(image As Bitmap) As String
- Dim toggle As Boolean = False
- Dim sb As New StringBuilder()
- For h As Integer = 0 To image.Height - 1
- For w As Integer = 0 To image.Width - 1
- Dim pixelColor As Color = image.GetPixel(w, h)
- Dim red As Integer = CInt((pixelColor.R + pixelColor.G + pixelColor.B) / 3)
- Dim green As Integer = CInt((pixelColor.R + pixelColor.G + pixelColor.B) / 3)
- Dim blue As Integer = CInt((pixelColor.R + pixelColor.G + pixelColor.B) / 3)
- Dim grayColor As Color = Color.FromArgb(red, green, blue)
- If Not toggle Then
- Dim index As Integer = CInt((grayColor.R * 10) / 255)
- sb.Append(_AsciiChars(index))
- End If
- Next
- If Not toggle Then
- sb.Append("<BR>")
- toggle = True
- Else
- toggle = False
- End If
- Next
- Return sb.ToString()
- End Function
- Private _AsciiChars As String() = {"#", "#", "@", "%", "=", "+", "*", ":", "-", ".", "", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
- Sub StartDisplay(URL As String)
- Dim image As New Bitmap(URL, True)
- Dim _Content = ConvertToAscii(image)
- Debug.Write(_Content)
Weiß jemand, woran das liegt und wie man das beheben kann?
Liebe Grüße
sothere
sothere