Computer Science Canada Full Colour Picture to Text (with ability to lock files) |
Author: | Cezna [ Fri Jun 18, 2010 3:19 pm ] |
Post subject: | Full Colour Picture to Text (with ability to lock files) |
This is a program I made over the past few days (for anyone who read my topic in General Discussion about deleting a file off my flash drive, this is the file I deleted and had to rewrite). You load an image into the program, and it scans the red, green and blue elements of each pixel and saves them to another file as text. I made it save the files with the extension .lol, just for fun, but it would be extremely simple to make it write to a .txt (there is just one line, where the .lol extension is added, that would have to be changed). Many of you probably realize the implications of this, that you could have your entire game saved to one file, pictures and all (well not music, since to my knowledge, the only thing Turing can do to a music file is play and stop it, if there is more please let me know). The only obstacle to this is that you would have to use put and get instead of write and read (I used the later set of commands, as I found that this allows the program to run much faster, but if you are only ever going to run it once to put a picture into your program's source code, the time it would take probably wouldn't be a big deal). Anyway, another big aspect of the program is that when you scan the image and convert it to a .lol, you have the option to lock it with an alphanumerical key. This key must then be input when decrypting the file, or else the file cannot be read properly and a whole bunch of random coloured dots are the result, giving you static instead of an image. This is done using Rand.Set, with the seed being the key, and then Rand.Int to change the colour values of each dot, so that the information that is put into the file is useless without the key that you used during encryption. Once the file is decrypted from the .lol format, it can then be saved as an image again, using a built in command, not just the save button on the run window button bar. Anyway, there are better instructions on the main menu, and if anyone dosn't know how the methods I explained above work, but wants to know, I would be glad to explain. If anyone finds any bugs, or has any ideas on how I could improve the program, please post them. Lastly, I have two files attached below, the source code, and a good image that is small enough to be scanned quickly to show off the program. |
Author: | chrisbrown [ Fri Jun 18, 2010 3:32 pm ] |
Post subject: | RE:Full Colour Picture to Text (with ability to lock files) |
Some sort of compression might be a good idea... my 198 KB .jpg turned into a 25.8 MB .lol file. Cool idea though. |
Author: | Cezna [ Fri Jun 18, 2010 3:41 pm ] |
Post subject: | RE:Full Colour Picture to Text (with ability to lock files) |
Yeah, I was trying to work on compression, but don't have a good enough grasp of the concept to really do much. If anyone has any ideas, I would welcome them. Anyway, thanks for the compliment. |
Author: | Monduman11 [ Fri Jun 18, 2010 9:58 pm ] |
Post subject: | RE:Full Colour Picture to Text (with ability to lock files) |
wow this is actually pretty sick.. how long did it take to do? |
Author: | copthesaint [ Sat Jun 19, 2010 1:18 am ] |
Post subject: | RE:Full Colour Picture to Text (with ability to lock files) |
ehh there are lots of these manduman11, there has only been one good one I've seen is http://compsci.ca/v3/viewtopic.php?t=16513 |
Author: | Zren [ Sat Jun 19, 2010 1:22 am ] |
Post subject: | RE:Full Colour Picture to Text (with ability to lock files) |
Try different data types. Right now you've got : ~ filesize = w * h * 3 (1 for each RGB value) * size of data type real as a data type is 8 bytes. 24 bytes for each pixel. So a 100x100 picture will be 240Kb. Just changing the filetype of these variables from real to real4 would cut the size in half, though still 4 times the size of a regular bitmap. Bitmaps (the most uncompressed popular filetype) can be thought of as roughly: w*h*3*1 byte Bitmaps use the equivalent of 3 nat1 (0 .. 255) variables per pixel, or 3 bytes per pixel versus the real's 24 bytes/pixel. Though I'm not 100% sure on any possible errors from using real4 with the lessened accuracy, though I doubt it will matter. It's the easiest way to cut filesize in half. |
Author: | Cezna [ Sat Jun 19, 2010 2:18 pm ] |
Post subject: | RE:Full Colour Picture to Text (with ability to lock files) |
@ Monduman It took me two days (three if you count rewritting it, since I accidentally deleted it) @ copthesaint It was acutally that program that inspired me to make this, as I wanted to know how to scan full colours in Turing, but I did it rather differently from the way StealthArcher accomplished his. In the ned though, they accomplish the same thing, just mine has encrpyption, and his final version has a more user friendly menu (mine was just really an experiment, so I didn't want to go all out on GUI) @ Zren Sounds like a great idea, and I think I will include it as an option (due to possible loss of detail, as you mentioned) If I do implement the change, I will post an updated version. |