News for hackers. Stuff that matters.
Re:Writing code with MS Paint by JoachimSchipper on Wednesday April 06, 2011 @09:02AM (#2414905)
C code is too "random" to produce nice images. You can use the least significant bits to hold some data; Google "steganography" (this is just the most basic).
Re:Writing code with MS Paint by JonnieCache on Wednesday April 06, 2011 @09:14AM (#2414941)
>C code is too "random" to produce nice images

In a world where it is possible to compute a file that contains its own MD5, I wouldn't bet on this. Wish I could find the link, there was some feted programmer who had a friend that bet him such a thing was not possible. He proceeded to write an algorithm that found such a file by brute force.

I wouldn't count on the eventual C being pretty though.

See also: electronic musicians hiding pictures in their music http://www.bastwood.com/?page_id=10

Re:Writing code with MS Paint by JoachimSchipper on Wednesday April 06, 2011 @09:27AM (#2414985)
You're right: sane C code is too "random" to produce nice images. ;-)
Re:Writing code with MS Paint by JonnieCache on Wednesday April 06, 2011 @10:06AM (#2415101)
One hacker's insanity is another's pastime.

http://www.de.ioccc.org/main.html

Re:Writing code with MS Paint by JoachimSchipper on Wednesday April 06, 2011 @10:21AM (#2415156)
Yeah, that's what I thought of too. Has it been done yet?
Re:Writing code with MS Paint by mrcharles on Wednesday April 06, 2011 @10:01AM (#2415087)
Example of a python script in a bitmap:

http://www.bluh.org/codemap.bmp

Ultimately it's never going to be pretty if it's human readable as the range of bytes used will make a lot of greyish tones.

C/C++ wouldn't look a lot different I doubt, but if you want you can grab my python script (PIL required) and pack some source files and see for yourself:

http://www.github.com/mrcharles/codemap

(script has some bugs with alignment, but other than that, works)

Re:Writing code with MS Paint by RodgerTheGreat on Wednesday April 06, 2011 @09:34AM (#2415007)
In Java, source files can contain unicode escapes[1] of the form '\uXXXX' which are expanded prior to tokenization. In effect this gives you several options for what characters can exist in a given "pixel". I think that this, combined with careful application of whitespace and comments, should easily provide enough flexibility to make arbitrary code look roughly like a desired bitmap.

[1] http://java.sun.com/docs/books/jls/second_edition/html/lexic...

Re:Writing code with MS Paint by JoachimSchipper on Wednesday April 06, 2011 @09:48AM (#2415050)
Just \uXXXX (or C trigraphs etc) doesn't give you much to play with, and I'd say that selectively tokenizing Java is cheating.