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.

186 lines
7.7 KiB

  1. ===========================
  2. PNG: The Definitive Guide
  3. ===========================
  4. Source Code
  5. Chapters 13, 14 and 15 of "PNG: The Definitive Guide" discuss three free,
  6. cross-platform demo programs that show how to use the libpng reference
  7. library: rpng, rpng2 and wpng. rpng and rpng2 are viewers; the first is
  8. a very simple example that that shows how a standard file-viewer might use
  9. libpng, while the second is designed to process streaming data and shows
  10. how a web browser might be written. wpng is a simple command-line program
  11. that reads binary PGM and PPM files (the ``raw'' grayscale and RGB subsets
  12. of PBMPLUS/NetPBM) and converts them to PNG.
  13. The source code for all three demo programs currently compiles under
  14. Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
  15. [email protected], for making the necessary changes for OpenVMS and for
  16. providing an appropriate build script.) Build instructions can be found
  17. below.
  18. Files:
  19. README this file
  20. LICENSE terms of distribution and reuse (BSD-like or GNU GPL)
  21. COPYING GNU General Public License (GPL)
  22. Makefile.unx Unix makefile
  23. Makefile.w32 Windows (MSVC) makefile
  24. makevms.com OpenVMS build script
  25. rpng-win.c Windows front end for the basic viewer
  26. rpng-x.c X Window System (Unix, OpenVMS) front end
  27. readpng.c generic back end for the basic viewer
  28. readpng.h header file for the basic viewer
  29. rpng2-win.c Windows front end for the progressive viewer
  30. rpng2-x.c X front end for the progressive viewer
  31. readpng2.c generic back end for the progressive viewer
  32. readpng2.h header file for the progressive viewer
  33. wpng.c generic (text) front end for the converter
  34. writepng.c generic back end for the converter
  35. writepng.h header file for the converter
  36. toucan.png transparent PNG for testing (by Stefan Schneider)
  37. Note that, although the programs are designed to be functional, their
  38. primary purpose is to illustrate how to use libpng to add PNG support to
  39. other programs. As such, their user interfaces are crude and definitely
  40. are not intended for everyday use.
  41. Please see http://www.libpng.org/pub/png/pngbook.html for further infor-
  42. mation and links to the latest version of the source code, and Chapters
  43. 13-15 of the book for detailed discussion of the three programs.
  44. Greg Roelofs
  45. http://pobox.com/~newt/greg_contact.html
  46. 16 March 2008
  47. BUILD INSTRUCTIONS
  48. - Prerequisites (in order of compilation):
  49. - zlib http://zlib.net/
  50. - libpng http://www.libpng.org/pub/png/libpng.html
  51. - pngbook http://www.libpng.org/pub/png/book/sources.html
  52. The pngbook demo programs are explicitly designed to demonstrate proper
  53. coding techniques for using the libpng reference library. As a result,
  54. you need to download and build both zlib (on which libpng depends) and
  55. libpng. A common build setup is to place the zlib, libpng and pngbook
  56. subdirectory trees ("folders") in the same parent directory. Then the
  57. libpng build can refer to files in ../zlib (or ..\zlib or [-.zlib]),
  58. and similarly for the pngbook build.
  59. Note that all three packages are designed to be built from a command
  60. line by default; those who wish to use a graphical or other integrated
  61. development environments are on their own.
  62. - Unix:
  63. Unpack the latest pngbook sources (which should correspond to this
  64. README file) into a directory and change into that directory.
  65. Copy Makefile.unx to Makefile and edit the PNG* and Z* variables
  66. appropriately (possibly also the X* variables if necessary).
  67. make
  68. There is no "install" target, so copy the three executables somewhere
  69. in your path or run them from the current directory. All three will
  70. print a basic usage screen when run without any command-line arguments;
  71. see the book for more details.
  72. - Windows:
  73. Unpack the latest pngbook sources (which should correspond to this
  74. README file) into a folder, open a "DOS shell" or "command prompt"
  75. or equivalent command-line window, and cd into the folder where you
  76. unpacked the source code.
  77. For MSVC, set up the necessary environment variables by invoking
  78. %devstudio%\vc\bin\vcvars32.bat
  79. where where %devstudio% is the installation directory for MSVC /
  80. DevStudio. If you get "environment out of space" errors under 95/98,
  81. create a desktop shortcut with "c:\windows\command.com /e:4096" as
  82. the program command line and set the working directory to the pngbook
  83. directory. Then double-click to open the new DOS-prompt window with
  84. a bigger environment and retry the commands above.
  85. Copy Makefile.w32 to Makefile and edit the PNGPATH and ZPATH variables
  86. appropriately (possibly also the "INC" and "LIB" variables if needed).
  87. Note that the names of the dynamic and static libpng and zlib libraries
  88. used in the makefile may change in later releases of the libraries.
  89. Also note that, as of libpng version 1.0.5, MSVC DLL builds do not work.
  90. This makefile therefore builds statically linked executables, but if
  91. the DLL problems ever get fixed, uncommenting the appropriate PNGLIB
  92. and ZLIB lines will build dynamically linked executables instead.
  93. Do the build by typing
  94. nmake
  95. The result should be three executables: rpng-win.exe, rpng2-win.exe,
  96. and wpng.exe. Copy them somewhere in your PATH or run them from the
  97. current folder. Like the Unix versions, the two windowed programs
  98. (rpng and rpng2) now display a usage screen in a console window when
  99. invoked without command-line arguments; this is new behavior as of
  100. the June 2001 release. Note that the programs use the Unix-style "-"
  101. character to specify options, instead of the more common DOS/Windows
  102. "/" character. (For example: "rpng2-win -bgpat 4 foo.png", not
  103. "rpng2-win /bgpat 4 foo.png")
  104. - OpenVMS:
  105. Unpack the pngbook sources into a subdirectory and change into that
  106. subdirectory.
  107. Edit makevms.com appropriately, specifically the zpath and pngpath
  108. variables.
  109. @makevms
  110. To run the programs, they probably first need to be set up as "foreign
  111. symbols," with "disk" and "dir" set appropriately:
  112. $ rpng == "$disk:[dir]rpng-x.exe"
  113. $ rpng2 == "$disk:[dir]rpng2-x.exe"
  114. $ wpng == "$disk:[dir]wpng.exe"
  115. All three will print a basic usage screen when run without any command-
  116. line arguments; see the book for more details. Note that the options
  117. style is Unix-like, i.e., preceded by "-" rather than "/".
  118. RUNNING THE PROGRAMS: (VERY) BRIEF INTRO
  119. rpng is a simple PNG viewer that can display transparent PNGs with a
  120. specified background color; for example,
  121. rpng -bgcolor \#ff0000 toucan.png
  122. would display the image with a red background. rpng2 is a progressive
  123. viewer that simulates a web browser in some respects; it can display
  124. images against either a background color or a dynamically generated
  125. background image. For example:
  126. rpng2 -bgpat 16 toucan.png
  127. wpng is a purely command-line image converter from binary PBMPLUS/NetPBM
  128. format (.pgm or .ppm) to PNG; for example,
  129. wpng -time < toucan-notrans.ppm > toucan-notrans.png
  130. would convert the specified PPM file (using redirection) to PNG, auto-
  131. matically setting the PNG modification-time chunk.
  132. All options can be abbreviated to the shortest unique value; for example,
  133. "-bgc" for -bgcolor (versus "-bgp" for -bgpat), or "-g" for -gamma.