all repos — mgba @ 81a52403a3583039f4e571f1516cd0efe4872c4b

mGBA Game Boy Advance Emulator

src/third-party/libpng/contrib/pngminus/README (view raw)

  1PngMinus
  2--------
  3(copyright Willem van Schaik, 1999)
  4
  5
  6License
  7-------
  8
  9Permission to use, copy, modify, and distribute this software and
 10its documentation for any purpose and without fee is hereby granted,
 11provided that the above copyright notice appear in all copies and
 12that both that copyright notice and this permission notice appear in
 13supporting documentation. This software is provided "as is" without
 14express or implied warranty.
 15
 16
 17Some history
 18------------
 19Soon after the creation of PNG in 1995, the need was felt for a set of
 20pnmtopng / pngtopnm utilities. Independantly Alexander Lehmann and I
 21(Willem van Schaik) started such a project. Luckily we discovered this
 22and merged the two together into pnmtopng.tar.gz, which is available
 23from a/o ftp://ftp.simplesystems.org/pub/libpng/png/.
 24
 25These two utilities have many, many options and make use of most of the
 26features of PNG, like gamma, alpha, sbit, text-chunks, etc. This makes
 27the utilities quite complex and by now not anymore very maintainable.
 28When we wrote these programs, libpng was still in an early stage.
 29Therefore, lots of the functionality that we put in our software can now
 30be done using transform-functions in libpng.
 31
 32Finally, to compile these programs, you need to have installed and
 33compiled three libraries: libpng, zlib and netpbm. Especially the latter
 34makes the whole setup a bit bulky. But that's unavoidable given the many
 35features of pnmtopng.
 36
 37
 38What now
 39--------
 40At this moment libpng is in a very stable state and can do much of the
 41work done in pnmtopng. Also, pnmtopng needs to be upgraded to the new
 42interface of libpng. Hence, it is time for a rewrite from the ground up
 43of pnmtopng and pngtopnm. This will happen in the near future (stay
 44tuned). The new package will get a different name to distinguish it from
 45the old one: PngPlus.
 46
 47To experiment a bit with the new interface of libpng, I started off with
 48a small prototype that contains only the basic functionality. It doesn't
 49have any of the options to read or write special chunks and it will do
 50no gamma correction. But this makes it also a simple program that is
 51quite easy to understand and can serve well as a template for other
 52software developments. (By now there are of course a couple of programs,
 53like Greg Roelofs' rpng/wpng, that can be used just as good.)
 54
 55
 56Can and can not
 57---------------
 58As this is the small brother of the future PngPlus, I called this fellow
 59PngMinus. Because I started this development in good-old Turbo-C, I
 60avoided the use the netpbm library, which requires DOS extenders. Again,
 61another reason to call it PngMinus (minus netpbm :-). So, part of the
 62program are some elementary routines to read / write pgm- and ppm-files.
 63It does not read b&w pbm-files.
 64
 65The downside of this approach is that you can not use them on images
 66that require blocks of memory bigger than 64k (the DOS version). For
 67larger images you will get an out-of-memory error.
 68
 69As said before, PngMinus doesn't correct for gamma. When reading
 70png-files you can do this just as well by piping the output of png2pnm
 71to pnmgamma, one of the standard PbmPlus tools. This same scenario will
 72most probably also be followed in the full-blown future PngPlus, with
 73the addition of course of the possibility to create gamma-chunks when
 74writing png-files.
 75
 76On the other hand it supports alpha-channels. When reading a png-image
 77you can write the alpha-channel into a pgm-file. And when creating an
 78RGB+A png-image, you just combine a ppm-file with a corresponding
 79pgm-file containing the alpha-channel. When reading, transparency chunks
 80are converted into an alpha-channel and from there on treated the same
 81way.
 82
 83Finally you can opt for writing ascii or binary pgm- and ppm-files. When
 84the bit-depth is 16, the format will always be ascii.
 85
 86
 87Using it
 88--------
 89To distinguish them from pnmtopng and PngPlus, the utilities are named
 90png2pnm and pnm2png (2 instead of to). The input- and output-files can
 91be given as parameters or through redirection. Therefore the programs
 92can be part of a pipe.
 93
 94To list the options type "png2pnm -h" or "pnm2png -h".
 95
 96
 97Just like Scandinavian furniture
 98--------------------------------
 99You have to put it together yourself. I did test the software under
100MS-DOS with Turbo-C 3.0 and under RedHat Linux 4.2 with gcc. In both
101cases I used libpng-1.0.4 and zlib-1.1.3. Later versions should be OK,
102however some older libpng versions have a bug in pngmem.c when using
103Turbo-C 3.0 (see below).
104
105You can build it using one of the two makefiles (make -f makefile.###)
106or use the batch/script files pngminus.bat / pngminus.sh. This assumes
107that you have built the libraries in ../libpng and ../zlib. Using Linux,
108make sure that you have built libpng with makefile.std and not
109makefile.linux (also called .lnx in earlier versions of libpng). The
110latter creates a .so shared-library, while the PngMinus makefile assumes
111a normal .a static library.
112
113If you create a ../pngsuite directory and then store the basn####.png
114files from PngSuite (http://www.schaik.com/pngsuite/) in there, you can
115test in one go the proper functioning of PngMinus, see png2pnm.bat and
116pnm2png.bat (or the .sh versions).
117
118
119Warranty
120-------
121Please, remember that this was just a small experiment to learn a few
122things. It will have many unforeseen features <vbg>. Who said bugs? Use
123it when you are in need for something simple or when you want to start
124developing your own stuff.
125
126
127The Turbo bug
128-------------
129** pngmem.old
130          hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
131          hptr += 16L;
132** pngmem.c
133          hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
134          hptr = hptr + 16L;
135**
136
137** pngmem.old
138          png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
139          hptr += (png_uint_32)65536L;
140** pngmem.c
141          png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
142          hptr = hptr + 65536L;
143**
144
145
146The end
147-------
148Willem van Schaik
149mailto:willem@schaik.com
150http://www.schaik.com/png/
151-------
152Oct 1999
153