Format fix 2012/vik/README.md + add alt code
Based on the author's description I made an alt version that should theoretically work in Windows though of course (thank goodness) I have no way to actually test it. Just like with 2011/vik I've only done this because part of issue #1 is to make entries work on as many systems as possible though it's not entirely clear to me that 'Windows' should even be considered a 'system' at all let alone one worthy of consideration :-) Updated .gitignore.
This commit is contained in:
1 parent
17b581640a
commit
ec1dd1c85d
5 files changed
+176
-48
No files matched your search
+78
-46
@@ -1,8 +1,8 @@
|
||||
# Best use of cocoa - Bronze award
|
||||
|
||||
Daniel Vik
|
||||
<daniel@vik.cc>
|
||||
<http://danielvik.com/>
|
||||
Daniel Vik
|
||||
<daniel@vik.cc>
|
||||
<http://danielvik.com/>
|
||||
|
||||
## To build:
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
make
|
||||
```
|
||||
|
||||
This entry requires [Zlib](http://www.zlib.net/).
|
||||
This entry requires [Zlib](https://www.zlib.net).
|
||||
|
||||
|
||||
## To run:
|
||||
|
||||
@@ -44,6 +45,16 @@ To extract the embedded PNG:
|
||||
./vik d encodedimg.png > restored.png
|
||||
```
|
||||
|
||||
There is an alternate version which might work for Windows. See Alternate code
|
||||
section below.
|
||||
|
||||
### INABIAF - it's not a bug it's a feature! :-)
|
||||
|
||||
The author stated that the program will crash if no argument is passed to the
|
||||
program or if invalid arguments or images of mismatching sizes or unsupported
|
||||
pixel formats though we note that your computer might also [halt and catch
|
||||
fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing)) :-)
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
@@ -53,45 +64,65 @@ To extract the embedded PNG:
|
||||
./vik d ioccc-in-chocolate.png > restored-ioccc.png
|
||||
```
|
||||
|
||||
### Alternate code:
|
||||
|
||||
Based on the author's description it should be able to get this entry to work
|
||||
for Windows. With his instructions [Cody Boone
|
||||
Ferguson](/winners.html#Cody_Boone_Ferguson) added the alternate version that
|
||||
does this for the few who might use Windows. To compile:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
```
|
||||
|
||||
Use `vik.alt` as you would `vik` above.
|
||||
|
||||
We're not sure whether we want to thank Cody or not for this :-) and he's not
|
||||
sure if he wants to be thanked either :-) but we appreciate it nonetheless.
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
References to chocolate had no effect on judging this entry. We
|
||||
guarantee it.
|
||||
|
||||
Can you discern hidden pieces of chocolate in `chocolate-in-ioccc.png`?
|
||||
Can you discern hidden pieces of chocolate in
|
||||
[chocolate-in-ioccc.png](chocolate-in-ioccc.png)?
|
||||
|
||||

|
||||
|
||||
## Author's remarks:
|
||||
|
||||
### Introduction
|
||||
|
||||
This program is a steganography application for embedding an image or text
|
||||
into another image as well as extracting the embedded image or text back.
|
||||
The program stores the embedded image or text in the low bits of the RGB
|
||||
values.
|
||||
This program is a [steganography](https://en.wikipedia.org/wiki/Steganography)
|
||||
application for embedding an image or text into another image as well as
|
||||
extracting the embedded image or text back. The program stores the embedded
|
||||
image or text in the low bits of the RGB values.
|
||||
|
||||
The program supports any 8 bit true color PNG images (RGB, RGBA, grayscale,
|
||||
and grayscale+alpha). The output image is always 8 bit RGB. When embedding
|
||||
The program supports any 8 bit true color PNG images (RGB, RGBA, greyscale,
|
||||
and greyscale+alpha). The output image is always 8 bit RGB. When embedding
|
||||
one image into another, the width and height needs to be the same.
|
||||
|
||||
The program only updates the IDAT and IHDR chunks of the source image. Any
|
||||
The program only updates the `IDAT` and `IHDR` chunks of the source image. Any
|
||||
additional chunks are copied into the resulting image.
|
||||
|
||||
### Bonus Extractor:
|
||||
|
||||
For some reason the chocolate image seems to have some special properties.
|
||||
Apart from being quite big and a little bit noisy, it appears that when
|
||||
embedded into another image and extracted, the bitmap data is also a valid
|
||||
brain$#@$ program. It is of course possible to get the bitmap data from the
|
||||
extracted image, and run it through any of the previous winning brain$#@$
|
||||
interpreters, but I thought it would be easier to include an interpreter in
|
||||
the program to avoid the hassle:
|
||||
For some reason the chocolate image seems to have some special properties.
|
||||
Apart from being quite big and a little bit noisy, it appears that when embedded
|
||||
into another image and extracted, the bitmap data is also a valid
|
||||
[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) program. It is of course
|
||||
possible to get the bitmap data from the extracted image, and run it through any
|
||||
of the previous winning brain$#@$ interpreters, but I thought it would be easier
|
||||
to include an interpreter in the program to avoid the hassle:
|
||||
|
||||
```sh
|
||||
./vik e ioccc.png chocolate.png > encodedimg.png
|
||||
./vik b encodedimg.png
|
||||
```
|
||||
|
||||
It is of course also possible to embed a brain$#@$ program as a text file
|
||||
It is of course also possible to embed a
|
||||
[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) program as a text file
|
||||
(as explained above) and decode it, e.g.:
|
||||
|
||||
```sh
|
||||
@@ -101,26 +132,25 @@ It is of course also possible to embed a brain$#@$ program as a text file
|
||||
|
||||
### Obfuscation
|
||||
|
||||
I really wanted to keep the program simple, so instead of adding multiple
|
||||
macros or helper methods that can be confusing, I placed all functionality
|
||||
in the main function. Main is called recursively and quite extensively, but
|
||||
it gives the benefit that all invocations of the function has the same
|
||||
parameters, argv and argc. This really helps readability, as a programmer
|
||||
doesn't need to remember several variable or function names. I also tried
|
||||
to reduce the number of keywords, and the program only has four for-loops
|
||||
followed by a single return statement. There is a little bit of use of the
|
||||
question mark operator, but this is really there to keep the program as
|
||||
simple as possible.
|
||||
I really wanted to keep the program simple, so instead of adding multiple macros
|
||||
or helper methods that can be confusing, I placed all functionality in the
|
||||
`main()` function. `main()` is called recursively and quite extensively, but it
|
||||
gives the benefit that all invocations of the function have the same parameters,
|
||||
`argv` and `argc`. This really helps readability, as a programmer doesn't need
|
||||
to remember several variable or function names. I also tried to reduce the
|
||||
number of keywords, and the program only has four for-loops followed by a single
|
||||
return statement. There is a little bit of use of the ternary (`?:`) operator,
|
||||
but this is really there to keep the program as simple as possible.
|
||||
|
||||
### Portability
|
||||
|
||||
The program is portable to most platforms that have zlib available. The
|
||||
only system dependency is that the program relies on writing binary data to
|
||||
stdout.
|
||||
The program is portable to most platforms that have [zlib](https://www.zlib.net)
|
||||
available. The only system dependency is that the program relies on writing
|
||||
binary data to stdout.
|
||||
|
||||
By default, Microsoft compilers adds carriage returns to new lines, and to
|
||||
By default, Microsoft compilers adds carriage returns to new lines, and to
|
||||
compile the program on this platform, the following line can be added after
|
||||
the variable declarations in the main declaration in order to run
|
||||
the variable declarations in the main declaration in order to run
|
||||
correctly:
|
||||
|
||||
```c
|
||||
@@ -129,31 +159,33 @@ _setmode(_fileno(stdout), 0x8000);
|
||||
|
||||
### Limitations
|
||||
|
||||
The program doesn’t have many error checks so passing in invalid arguments
|
||||
The program doesn't have many error checks so passing in invalid arguments
|
||||
or images of mismatching sizes, or unsupported pixel formats will cause the
|
||||
program to crash.
|
||||
|
||||
|
||||
### Extendability
|
||||
|
||||
Since a lot of care was taken to keep the code simple, it turned out to be
|
||||
quite easy to extend functionality. I did include a small brain$#@$ after I
|
||||
Since a lot of care was taken to keep the code simple, it turned out to be
|
||||
quite easy to extend functionality. I did include a small
|
||||
[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) after I
|
||||
realized that the chocolate image had some interesting properties.
|
||||
|
||||
But there is more functionality I added that didn’t fit within the size
|
||||
limits and could not remain included. For example, I added a method to
|
||||
format source code based on a PNG image. So the format of the program is
|
||||
But there is more functionality I added that didn't fit within the size
|
||||
limits and could not remain included. For example, I added a method to
|
||||
format source code based on a PNG image. So the format of the program is
|
||||
actually done by the program itself.
|
||||
|
||||
And to be honest, the chocolate image did not have a brain$#@$ program
|
||||
embedded to begin with. I added functionality to the program to embed a
|
||||
brain$#@$ into a PNG image and used it to create the image provided with
|
||||
And to be honest, the chocolate image did not have a
|
||||
[brain$#@$](https://en.wikipedia.org/wiki/Brainfuck) program
|
||||
embedded to begin with. I added functionality to the program to embed a
|
||||
brain$#@$ into a PNG image and used it to create the image provided with
|
||||
the entry.
|
||||
|
||||
I also added a method to analyze PNG images, to print the size and format,
|
||||
I also added a method to analyze PNG images, to print the size and format,
|
||||
as well as the scan line filters.
|
||||
|
||||
All these features were quite easy to add, much thanks to the (actually
|
||||
All these features were quite easy to add, much thanks to the (actually
|
||||
pretty good) design of the code.
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
Reference in new issue
Block a user