Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Converting files to images.

So I've been messing around with image manipulation lately in VB.net and also have been learning about binary and data, I then started making an app to do this which works (for very small files) well it works for larger files to but you might have to wait a year or two.

Basically anything > 50kb is OK

Here is an example, I have used my program to convert itself to an image here is the outcome.

If you scroll right to the end you will notice a section of yellow/orange pixels I use these pixels to store information such as the filename and type in.
Spoiler (Click to View)

Direct link to the image

To get the image above what my code does is convert the file to bytes (I tried posting the bytes in this thread but there is over 38,000 which froze my browser and HF has a limit to characters :P,
So instead I have posted them on PasteBin

My Programs Bytes

So as you can see each byte ranges from 0 to 255 which is perfect for RGB :D

From this I then used just the Red in the RGB as the variable.

I used a for loop to scan through each byte and convert it to a pixel using RGB like this
(thebyte, 0, 0)

Here is the exact code I used for setting each pixel.
Code
FileBitMap.SetPixel(i, 0, Color.FromArgb(Int(filebytes(i)), 0, 0))

Here is all my programs code

Code
Imports System.IO

Public Class Form1
    Dim bytestring As String = ""
    Dim bm2 As New Bitmap(10, 10)
    Dim tempdata As String = ""
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        OpenFileDialog1.ShowDialog()
        Dim filebytes As Array = File.ReadAllBytes(OpenFileDialog1.FileName)

        Dim FileBitMap As New Bitmap(filebytes.Length + OpenFileDialog1.SafeFileName.ToString.ToLower.Length, 1)

        For i As Integer = 0 To filebytes.Length - 1
            bytestring += filebytes(i).ToString + vbNewLine
            FileBitMap.SetPixel(i, 0, Color.FromArgb(Int(filebytes(i)), 0, 0))
            Me.Text = i.ToString + " out of " + (filebytes.Length - 1).ToString
            ProgressBar1.Maximum = filebytes.Length + OpenFileDialog1.SafeFileName.ToString.ToLower.Length
            ProgressBar1.Value = i
        Next
        Dim filenamez As String = OpenFileDialog1.SafeFileName.ToLower

        MsgBox(filenamez)
        Dim filenamecounter As Integer = 0
        For x As Integer = filebytes.Length - 1 To filebytes.Length - 1 + OpenFileDialog1.SafeFileName.ToString.ToLower.Length - 1
            Select Case filenamez(filenamecounter)
                Case "a"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(255, 100, 0))
                Case "b"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(254, 100, 0))
                Case "c"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(253, 100, 0))
                Case "d"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(252, 100, 0))
                Case "e"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(251, 100, 0))
                Case "f"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(250, 100, 0))
                Case "g"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(249, 100, 0))
                Case "h"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(248, 100, 0))
                Case "i"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(247, 100, 0))
                Case "j"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(246, 100, 0))
                Case "k"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(245, 100, 0))
                Case "l"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(244, 100, 0))
                Case "m"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(243, 100, 0))
                Case "n"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(242, 100, 0))
                Case "o"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(241, 100, 0))
                Case "p"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(240, 100, 0))
                Case "q"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(239, 100, 0))
                Case "r"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(238, 100, 0))
                Case "s"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(237, 100, 0))
                Case "t"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(236, 100, 0))
                Case "u"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(235, 100, 0))
                Case "v"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(234, 100, 0))
                Case "w"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(233, 100, 0))
                Case "x"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(232, 100, 0))
                Case "y"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(231, 100, 0))
                Case "z"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(230, 100, 0))
                Case " "
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(229, 100, 0))
                Case "."
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(228, 100, 0))
                Case "0"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(227, 100, 0))
                Case "9"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(226, 100, 0))
                Case "8"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(225, 100, 0))
                Case "7"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(224, 100, 0))
                Case "6"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(223, 100, 0))
                Case "5"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(222, 100, 0))
                Case "4"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(221, 100, 0))
                Case "3"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(220, 100, 0))
                Case "2"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(219, 100, 0))
                Case "1"
                    FileBitMap.SetPixel(x, 0, Color.FromArgb(218, 100, 0))
            End Select
            filenamecounter += 1
        Next
        PictureBox1.Image = FileBitMap
        bm2 = FileBitMap
        RichTextBox1.Text += bytestring
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        SaveFileDialog1.ShowDialog()
        bm2.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png)
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        OpenFileDialog1.ShowDialog()
        PictureBox2.ImageLocation = OpenFileDialog1.FileName
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        Dim FileBitMap As New Bitmap(PictureBox2.Image)
        Dim tempbytes As String = ""
        Dim finishedbytes(PictureBox2.Image.Width - 1) As Byte


        For x As Integer = 0 To PictureBox2.Image.Width - 1
            tempbytes += FileBitMap.GetPixel(x, 0).R.ToString + vbNewLine
            If FileBitMap.GetPixel(x, 0).G = 0 Then
                finishedbytes(x) = FileBitMap.GetPixel(x, 0).R
            Else
                Select Case FileBitMap.GetPixel(x, 0).R
                    Case 255
                        adt("a")
                    Case 254
                        adt("b")
                    Case 253
                        adt("c")
                    Case 252
                        adt("d")
                    Case 251
                        adt("e")
                    Case 250
                        adt("f")
                    Case 249
                        adt("g")
                    Case 248
                        adt("h")
                    Case 247
                        adt("i")
                    Case 246
                        adt("j")
                    Case 245
                        adt("k")
                    Case 244
                        adt("l")
                    Case 243
                        adt("m")
                    Case 242
                        adt("n")
                    Case 241
                        adt("o")
                    Case 240
                        adt("p")
                    Case 239
                        adt("q")
                    Case 238
                        adt("r")
                    Case 237
                        adt("s")
                    Case 236
                        adt("t")
                    Case 235
                        adt("u")
                    Case 234
                        adt("v")
                    Case 233
                        adt("w")
                    Case 232
                        adt("x")
                    Case 231
                        adt("y")
                    Case 230
                        adt("z")
                    Case 229
                        adt(" ")
                    Case 228
                        adt(".")
                    Case 227
                        adt("0")
                    Case 226
                        adt("9")
                    Case 225
                        adt("8")
                    Case 224
                        adt("7")
                    Case 223
                        adt("6")
                    Case 222
                        adt("5")
                    Case 221
                        adt("4")
                    Case 220
                        adt("3")
                    Case 219
                        adt("2")
                    Case 218
                        adt("1")
                End Select
            End If
        Next
        RichTextBox2.Text = tempbytes
        File.WriteAllBytes("PATH FOR SAVE DIRECTORY" + tempdata, finishedbytes)
    End Sub

    Sub adt(ByVal txt As String)
        tempdata += txt
    End Sub

End Class

To convert it back into the original file you basically do the opposite, instead of setting each pixel you read the values of each pixel and make a byte array from the RED values, once you have the byte array you can then use the WriteAllBytes function to write all of the bytes which will then recreate a working version of the file.


I'm probably not the first person to do this but what I made I thought was pretty impressive the only issue with my code is the speed, Scanning through every single byte is not the fastest method there is probably a much quicker way of doing it hopefully someone will let me know :D.

But as it is at the moment it works for small files and I think its just a cool concept. And for send files across the internet I think it would be pretty secure wouldn't it ? as only my program knows how to convert it back someone just looking at the image wouldn't be able to see what it is. I'm not saying its impossible but yea :P.


Here is the Download Link to my project hopefully someone can use it or improve it, if you can improve it I would love to know as I have rattled my brain trying to think of a quicker way of doing it. One way I thought of would be multi threading and splitting up the huge array into parts for each thread to do, but this still isn't that efficient.

Please leave your feedback below, sorry my explanation is probably absolute shit, I'm not the best at explaining things but I hope you get the idea. And looking at the thread it looks very dull sorry 🎉

Thanks Jake 🤝

[Image: DreddSig.gif]
That pastebin link froze my browser.
The thread is too long to read
(Sep 24, 2014 12:48 PM)+Haze Wrote:  That pastebin link froze my browser.
The thread is too long to read

I'm sorry but I only explained the basics there is loads I missed out but anyone with a fair bit of VB knowledge will hopefully understand my messy code.

[Image: DreddSig.gif]
(Sep 24, 2014 12:48 PM)+Haze Wrote:  That pastebin link froze my browser.
The thread is too long to read

You can't read ~500 words?
Poor you
[Image: jlscvfi.png]
(Sep 24, 2014 03:35 PM)NETExplorer Wrote:  You can't read ~500 words?
Poor you

38912 lines to be exact :D

Takes like 10 seconds to load for me.

[Image: DreddSig.gif]
(Sep 24, 2014 03:35 PM)NETExplorer Wrote:  You can't read ~500 words?
Poor you

>Implying you're talking about OPs thread word count.

[Image: xcvuRFv.png]

Next time come correct.
(Sep 24, 2014 04:32 PM)+Haze Wrote:  >Implying you're talking about OPs thread word count.

[Image: xcvuRFv.png]

Next time come correct.

You can read that, its like the equivalent to a small shitty E-Book on how to become a millionaire overnight, that you pay like $40 bucks for.

Spoiler (Click to View)

[Image: DreddSig.gif]
I like this innovations and idea's, you got my vote kiddo.

I made a similair application that looked alote like Qr-code encoding embbed a message into a image.
(Sep 24, 2014 04:41 PM)TheBarret Wrote:  I like this innovations and idea's, you got my vote kiddo.

I made a similair application that looked alote like Qr-code encoding embbed a message into a image.

Nice I originally started on something like that, I encoded strings into images and back again, then moved on to files.

[Image: DreddSig.gif]
(Sep 24, 2014 04:32 PM)+Haze Wrote:  >Implying you're talking about OPs thread word count.

[Image: xcvuRFv.png]

Next time come correct.

How about next time you remove the code tags from the count?
[Image: euFzqra.png]

You big, hurting vagina.
[Image: jlscvfi.png]
Theses topics always seem interesting, touching bytes and pixels..
What you can do with all that information.

I'v done something similar (not at all.), because i saw in a movie something spy like (it's pretty stupid), it was replacing bytes to an image by text in byte, in fonction of which bytes the program was converting the image could get pretty "glitched.". Something i thought intersting at the time. But still pretty stupid to be used as a spy --' (movies.)
Don't let them get at ya kiddo, ive done stupid things, but i tell ya what, stupid and mistakes is what happens before success, they go hand in hand. Make them and if it takes you 100 mistakes, then 100 mistakes it will be, eventually it only goes up and not down. All the mistakes i made, is what made me right now. and i do whatever i like, i program whatever desire i have. so you go, do your thing.

I have spoken. -B


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by Johnny CacheJan 23, 2021 11:08 AM 3 239 Jan 23, 2021 11:08 AM
Last Post: Shellc0de™
[.NET] by N3w8i3H4ck3rMay 9, 2015 01:02 AM 7 183 May 9, 2015 01:02 AM
Last Post: Anemone¹
[.NET] by Meerkat.Feb 13, 2013 11:08 AM 36 3,398 Feb 13, 2013 11:08 AM
Last Post: li0nsar3c00l