Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
5.8 KiB

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