671242f350d172e106580348e24bab66b0d7e6a5vboxsyncPngMinus
671242f350d172e106580348e24bab66b0d7e6a5vboxsync--------
671242f350d172e106580348e24bab66b0d7e6a5vboxsync(copyright Willem van Schaik, 1999)
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncLicense
671242f350d172e106580348e24bab66b0d7e6a5vboxsync-------
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncPermission to use, copy, modify, and distribute this software and
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncits documentation for any purpose and without fee is hereby granted,
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncprovided that the above copyright notice appear in all copies and
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncthat both that copyright notice and this permission notice appear in
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncsupporting documentation. This software is provided "as is" without
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncexpress or implied warranty.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncSome history
671242f350d172e106580348e24bab66b0d7e6a5vboxsync------------
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncSoon after the creation of PNG in 1995, the need was felt for a set of
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncpnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I
671242f350d172e106580348e24bab66b0d7e6a5vboxsync(Willem van Schaik) started such a project. Luckily we discovered this
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncand merged the two together into pnmtopng.tar.gz, which is available
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncfrom a/o ftp://swrinde.nde.swri.edu/pub/png/.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncThese two utilities have many, many options and make use of most of the
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncfeatures of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncthe utilities quite complex and by now not anymore very maintainable.
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncWhen we wrote these programs, libpng was still in an early stage.
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncTherefore, lots of the functionality that we put in our software can now
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncbe done using transform-functions in libpng.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncFinally, to compile these programs, you need to have installed and
671242f350d172e106580348e24bab66b0d7e6a5vboxsynccompiled three libraries: libpng, zlib and netpbm. Especially the latter
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncmakes the whole setup a bit bulky. But that's unavoidable given the many
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncfeatures of pnmtopng.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncWhat now
671242f350d172e106580348e24bab66b0d7e6a5vboxsync--------
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncAt this moment libpng is in a very stable state and can do much of the
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncwork done in pnmtopng. Also, pnmtopng needs to be upgraded to the new
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncinterface of libpng. Hence, it is time for a rewrite from the ground up
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncof pnmtopng and pngtopnm. This will happen in the near future (stay
671242f350d172e106580348e24bab66b0d7e6a5vboxsynctuned). The new package will get a different name to distinguish it from
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncthe old one: PngPlus.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncTo experiment a bit with the new interface of libpng, I started off with
671242f350d172e106580348e24bab66b0d7e6a5vboxsynca small prototype that contains only the basic functionality. It doesn't
671242f350d172e106580348e24bab66b0d7e6a5vboxsynchave any of the options to read or write special chunks and it will do
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncno gamma correction. But this makes it also a simple program that is
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncquite easy to understand and can serve well as a template for other
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncsoftware developments. (By now there are of course a couple of programs,
671242f350d172e106580348e24bab66b0d7e6a5vboxsynclike Greg Roelofs' rpng/wpng, that can be used just as good.)
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncCan and can not
671242f350d172e106580348e24bab66b0d7e6a5vboxsync---------------
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncAs this is the small brother of the future PngPlus, I called this fellow
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncPngMinus. Because I started this development in good-old Turbo-C, I
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncavoided the use the netpbm library, which requires DOS extenders. Again,
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncanother reason to call it PngMinus (minus netpbm :-). So, part of the
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncprogram are some elementary routines to read / write pgm- and ppm-files.
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncIt does not read b&w pbm-files.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncThe downside of this approach is that you can not use them on images
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncthat require blocks of memory bigger than 64k (the DOS version). For
671242f350d172e106580348e24bab66b0d7e6a5vboxsynclarger images you will get an out-of-memory error.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncAs said before, PngMinus doesn't correct for gamma. When reading
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncpng-files you can do this just as well by piping the output of png2pnm
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncto pnmgamma, one of the standard PbmPlus tools. This same scenario will
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncmost probably also be followed in the full-blown future PngPlus, with
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncthe addition of course of the possibility to create gamma-chunks when
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncwriting png-files.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncOn the other hand it supports alpha-channels. When reading a png-image
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncyou can write the alpha-channel into a pgm-file. And when creating an
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncRGB+A png-image, you just combine a ppm-file with a corresponding
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncpgm-file containing the alpha-channel. When reading, transparency chunks
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncare converted into an alpha-channel and from there on treated the same
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncway.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncFinally you can opt for writing ascii or binary pgm- and ppm-files. When
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncthe bit-depth is 16, the format will always be ascii.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncUsing it
671242f350d172e106580348e24bab66b0d7e6a5vboxsync--------
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncTo distinguish them from pnmtopng and PngPlus, the utilities are named
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncpng2pnm and pnm2png (2 instead of to). The input- and output-files can
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncbe given as parameters or through redirection. Therefore the programs
671242f350d172e106580348e24bab66b0d7e6a5vboxsynccan be part of a pipe.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncTo list the options type "png2pnm -h" or "pnm2png -h".
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncJust like Scandinavian furniture
671242f350d172e106580348e24bab66b0d7e6a5vboxsync--------------------------------
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncYou have to put it together yourself. I did test the software under
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncMS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both
671242f350d172e106580348e24bab66b0d7e6a5vboxsynccases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK,
671242f350d172e106580348e24bab66b0d7e6a5vboxsynchowever some older libpng versions have a bug in pngmem.c when using
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncTurbo-C 3.0 (see below).
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncYou can build it using one of the two makefiles (make -f makefile.###)
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncor use the batch/script files pngminus.bat / pngminus.sh. This assumes
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncthat you have built the libraries in ../libpng and ../zlib. Using Linux,
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncmake sure that you have built libpng with makefile.std and not
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncmakefile.linux (also called .lnx in earlier versions of libpng). The
671242f350d172e106580348e24bab66b0d7e6a5vboxsynclatter creates a .so shared-library, while the PngMinus makefile assumes
671242f350d172e106580348e24bab66b0d7e6a5vboxsynca normal .a static library.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncIf you create a ../pngsuite directory and then store the basn####.png
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncfiles from PngSuite (http://www.schaik.com/pngsuite/) in there, you can
671242f350d172e106580348e24bab66b0d7e6a5vboxsynctest in one go the proper functioning of PngMinus, see png2pnm.bat and
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncpnm2png.bat (or the .sh versions).
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncWarranty
671242f350d172e106580348e24bab66b0d7e6a5vboxsync-------
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncPlease, remember that this was just a small experiment to learn a few
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncthings. It will have many unforeseen features <vbg>. Who said bugs? Use
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncit when you are in need for something simple or when you want to start
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncdeveloping your own stuff.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncThe Turbo bug
671242f350d172e106580348e24bab66b0d7e6a5vboxsync-------------
671242f350d172e106580348e24bab66b0d7e6a5vboxsync** pngmem.old
671242f350d172e106580348e24bab66b0d7e6a5vboxsync hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
671242f350d172e106580348e24bab66b0d7e6a5vboxsync hptr += 16L;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync** pngmem.c
671242f350d172e106580348e24bab66b0d7e6a5vboxsync hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
671242f350d172e106580348e24bab66b0d7e6a5vboxsync hptr = hptr + 16L;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync**
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync** pngmem.old
671242f350d172e106580348e24bab66b0d7e6a5vboxsync png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync hptr += (png_uint_32)65536L;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync** pngmem.c
671242f350d172e106580348e24bab66b0d7e6a5vboxsync png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync hptr = hptr + 65536L;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync**
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncThe end
671242f350d172e106580348e24bab66b0d7e6a5vboxsync-------
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncWillem van Schaik
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncmailto:willem@schaik.com
671242f350d172e106580348e24bab66b0d7e6a5vboxsynchttp://www.schaik.com/png/
671242f350d172e106580348e24bab66b0d7e6a5vboxsync-------
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncOct 1999
671242f350d172e106580348e24bab66b0d7e6a5vboxsync