Files
ioccc/2012/vik
Landon Curt Noll c5848302e8 add new topbar, improve the look & feel of web pages
Thank you, @chris-sab, for your excellent work and for helping us
commit this alpha version of the topbar.

As part of this work, the following HTML sections were removed:

* begin-row
* begin-leftcolumn
* sidenav
* end-leftcolumn
* begin-rightcolumn
* before-content
* end-rightcolumn
* end-row.default

Also added a new HTML section, just above the "header" section:

* topbar

The web site now as a more modern looking topbar, thanks to the
work of the contractor (GitHub user @chris-sab) who is working on
issue #2273.

Performed `make www` to implement the above and test under macOS.

TODO: Fix the Responsive Web Design to deal with
      the new topbar system.

TODO: Improve the topbar.  What is there now is
      just an alpha version.

TODO: Decide what to do with `png/ioccc.png`.
      Remove it make selective use of the image on certain top level
      pages lower down?

TODO: The changes to `ioccc.css` causes some
      formatting problems with pages such as `location.html` (missing
      blank lines).  Fix formatting problems as needed.

TODO: Fix the "Nu HTML check this web page"
      links on things like the year level _YYYY/index.html_ pages.

TODO: Correct all HTML errors, warnings and perhaps
      informative messages from the Nu HTML check.

TODO: Consider adding color (colour) to the
      web pages in such a way that people with color perception
      challenges can still use the web site.

TODO: For those web browsers that have and allow
      JavaScript, make use of technology such as [Code
      Mirror](https://codemirror.net/) to directly render source
      code (C, shell, Makefile, etc.) with syntax coloring (colouring)
      directly in the browser.  For non-JavaScript browsers, fallback
      to the current use of GitHub source code viewing.
2024-04-16 17:28:39 -07:00
..
2020-12-30 16:57:03 -08:00
2020-12-30 16:57:03 -08:00
2020-12-30 16:57:03 -08:00
2023-07-06 21:49:38 -07:00

To build:

    make

This entry requires Zlib.

There is an alternate version which might work for Windows. See Alternate code section below.

Bugs and (Mis)features:

The current status of this entry is:

    STATUS: INABIAF - please **DO NOT** fix

For more detailed information see 2012 vik bugs.

To use:

To embed text (from file or command line):

    ./vik e base.png filename > encodedimg.png

or

    ./vik e base.png SomeRandomText > encodedimg.png

To extract the embedded text:

    ./vik d encodedimg.png

To embed a PNG into another:

    ./vik e base.png source.png > encodedimg.png

To extract the embedded PNG:

    ./vik d encodedimg.png > restored.png

Try:

    ./try.sh

Alternate code:

For those few who might use Windows this alternate code might work.

Alternate build:

    make alt

Alternate use:

Use vik.alt as you would vik above.

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?

chocolate in ioccc

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.

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 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 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 brainfuck interpreters, but I thought it would be easier to include an interpreter in the program to avoid the hassle:

    ./vik e ioccc.png chocolate.png > encodedimg.png
    ./vik b encodedimg.png

It is of course also possible to embed a brainfuck program as a text file (as explained above) and decode it, e.g.:

    ./vik e ioccc.png .+[.+] > encodedimg.png
    ./vik b encodedimg.png

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 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.

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 correctly:

    _setmode(_fileno(stdout), 0x8000);

NOTE: this is what the Alternate code does.

Limitations

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 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 actually done by the program itself.

And to be honest, the chocolate image did not have a brainfuck program embedded to begin with. I added functionality to the program to embed a brainfuck 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, as well as the scan line filters.

All these features were quite easy to add, much thanks to the (actually pretty good) design of the code.