Hacker News new | past | comments | ask | show | jobs | submit login

The maker of the picture wrote the code first in a text editor, and then for each triple of ASCII characters he found the corresponding RGB value, and set one pixel to it.

Since the bitmap is just a header (the mojibake you see at the start of the text file) and then a bunch of data bytes, the data bytes can be read as plain text again.




Some other things to note:

He is filling in the image from left-to-right, bottom-to-top. That's the scanline order of the data in BMP files, which means he is entering the code in the order it appears in the file.

Also, the image he is filling in is eight pixels wide. This is important because the row data in BMP files must be padded to a multiple of four bytes. Each pixel in a 24-bit image takes three bytes. If he had picked a width that wasn't a multiple of four, he would have had garbage padding bytes in the middle of his code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: