Hey guys, I have a working function for converting text into pixels but I'm having trouble converting the pixels back to text. Reason for that is that I did copy this function off of another forum. The problem with the conversion back to text is that it doesn't convert all the text. I tried changing it various different ways but I can't get it to work. The problem lies that it only reads 1000 characters from the pixels. I made that bigger but that doesn't work because it leaves alot of white spaces and in turn, I then can't convert the text From Base64 String. Can somebody help me recode the pixels to text function please?! Here's the code and thanks in advance...
Code:
Function Text2Pixels(ByVal save As Boolean, ByVal data As String)
Dim BMP As New Bitmap(1000, 1000)
Dim kkl As Integer = 1
Dim gg As Integer = 1
Dim tt As New Random(kkl)
For Each c As Char In data
If kkl >= 1000 Then
gg = gg + 1
kkl = 1
End If
Dim hh As Integer = Asc(c)
BMP.SetPixel(kkl, gg, Color.FromArgb(hh, tt.Next(256), tt.Next(256)))
kkl = kkl + 1
Next
If save = True Then
BMP.Save(Application.StartupPath & "\pic.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
End If
Return BMP
End Function
-------------------------------------------------------------------------------------------
Function Pixels2Text(ByVal bitm As Bitmap)
Dim picture As New Bitmap(bitm, 1000, 1000)
Dim c As Color
Dim pixc As Integer = 1
Dim gg As Integer = 1
Dim result As String
For i = 1 To 1000
If pixc >= 1000 Then
gg = gg + 1
pixc = 1
End If
c = picture.GetPixel(pixc, gg)
Dim value As Integer = Convert.ToInt16(c.R)
Dim svalue As Integer = value.ToString
result = result + ChrW(svalue)
pixc = pixc + 1
Next
Return result
End Function