![]() |
|
[.NET] Converting files to images. - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Converting files to images. (/showthread.php?tid=4460581) |
Converting files to images. - Dredd - Sep 24, 2014 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.IOTo 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 🤝 * - +Haze - Sep 24, 2014 That pastebin link froze my browser. The thread is too long to read * - Dredd - Sep 24, 2014 (Sep 24, 2014 12:48 PM)+Haze Wrote: That pastebin link froze my browser. 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. * - NETExplorer - Sep 24, 2014 (Sep 24, 2014 12:48 PM)+Haze Wrote: That pastebin link froze my browser. You can't read ~500 words? Poor you * - Dredd - Sep 24, 2014 (Sep 24, 2014 03:35 PM)PatPositron Wrote: You can't read ~500 words? 38912 lines to be exact :D Takes like 10 seconds to load for me. * - +Haze - Sep 24, 2014 (Sep 24, 2014 03:35 PM)PatPositron Wrote: You can't read ~500 words? >Implying you're talking about OPs thread word count. ![]() Next time come correct. * - Dredd - Sep 24, 2014 (Sep 24, 2014 04:32 PM)+Haze Wrote: >Implying you're talking about OPs thread word count. 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) * - TheBarret - Sep 24, 2014 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. * - Dredd - Sep 24, 2014 (Sep 24, 2014 04:41 PM)TheBarret Wrote: I like this innovations and idea's, you got my vote kiddo. Nice I originally started on something like that, I encoded strings into images and back again, then moved on to files. * - NETExplorer - Sep 24, 2014 (Sep 24, 2014 04:32 PM)+Haze Wrote: >Implying you're talking about OPs thread word count. How about next time you remove the code tags from the count? ![]() You big, hurting vagina. * - Onin42 - Sep 27, 2014 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.) * - TheBarret - Sep 27, 2014 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 |