ÿþ<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>AllegroPNG</title> <style type="text/css" media="screen"> <!-- body { font-family: "Palatino Linotype", serif; text-align: justify; } #container { margin-left: auto; margin-right: auto; max-width: 40em; } .note { border: 1px solid darkblue; padding: 5px; background-color: #DDF; } .note em { font-weight: bold; } h1, h2, h3, .menu { font-family: "Trebuchet MS", sans-serif; } pre { border: 1px solid grey; background-color: lightgrey; padding-left: 1em; } dt { font-family: monospace; font-weight: bold; } .menu { width: 10em; float: left; border: 3px solid darkblue; background: lightgrey; text-align: left; padding: 0; font-weight: bold; } .menu li { list-style-type: none; padding-bottom: 1ex; } .menu ul { margin: 0; padding: 1ex; } .menu a:hover { background-color: white; } .menu .selected { background-color: #eee; } --> </style> </head> <body> <div class="menu"> <ul> <li class="selected"><a href="index.html">AllegroPNG</a></li> <li><a href="octree.html">Octree quantization for Allegro</a></li> <li><a href="inflate.html">Inflate implementation</a></li> <li><a href="gstream.html">GStream</a></li> <li><a href="http://sourceforge.net/project/showfiles.php?group_id=164908">Downloads</a></li> <li><a href="http://alpng.svn.sourceforge.net/viewvc/alpng/">Subversion repository</a></li> <li><a href="http://sourceforge.net/projects/alpng">SourceForge Project page</a></li> <li><a href="http://mol1111.users.sourceforge.net/">My homepage</a></li> </ul> </div> <div id="container"> <h1 xmlns="">AllegroPNG (alpng)</h1> <p xmlns=""> This library servers for displaying PNG images in programs using the <a href="http://alleg.sourceforge.net/">Allegro</a> multimedia library. It's completely standalone, it doesn't require <a href="http://libpng.org/pub/png/libpng.html">libpng</a> nor <a href="http://zlib.net/">zlib</a> (however it can use <a href="http://zlib.net/">zlib</a> if installed). </p> <p class="note" xmlns=""><em>Note: </em> If you have <a href="http://libpng.org/pub/png/libpng.html">libpng</a> installed you can try to use <a href="http://tjaden.strangesoft.net/loadpng/">loadpng</a> library instead of alpng. <a href="http://tjaden.strangesoft.net/loadpng/">loadpng</a> is faster and supports some additional features like gama. It also exists for longer time so it's more tested. </p> <p xmlns=""> SourceForge project with download, Subversion repository etc. is available <a href="http://sourceforge.net/projects/alpng">here</a>. </p> <h2 xmlns="">Using alpng</h2> First of all you have to <tt xmlns="">#include &lt;alpng.h&gt;</tt>. <dl xmlns=""> <dt id="alpng_init">void alpng_init(void)</dt> <dd> You don't have to call this function, however if you do it will register the PNG extension in the <a href="http://alleg.sourceforge.net/">Allegro</a> library so you will be able to use <a href="http://alleg.sourceforge.net/onlinedocs/en/alleg010.html#load_bitmap"><tt>load_bitmap</tt> </a>, <a href="http://alleg.sourceforge.net/onlinedocs/en/alleg010.html#save_bmp"><tt>save_bitmap</tt> </a> and datafiles with PNG files. </dd> <dt>BITMAP* load_png(const char* filename, RGB* pal)</dt> <dd> Loads BITMAP from file. Returns NULL on error. See <a href="http://alleg.sourceforge.net/onlinedocs/en/alleg010.html#load_bitmap"><tt>load_bitmap</tt> </a> for details. Follows all <a href="http://alleg.sourceforge.net/">Allegro</a> conversion rules as described there, except that if file contains palette (PLTE chunk, not sPLT) it will be used when the <a href="http://alleg.sourceforge.net/onlinedocs/en/alleg010.html#load_bitmap"><tt>load_bitmap</tt> </a> documentation says that <tt>generate_optimized_palette</tt> will be used. Also, by default, this library doesn't use <tt>generate_optimized_palette</tt> at all, if the library needs to generate palette it will use its own octree quantization. You can however disable this during installation, see <a href="#octree">below</a>. </dd> <dt>BITMAP* load_png_pf(PACKFILE* f, RGB* pal)</dt> <dd> Loads BITMAP from an already open packfile. Returns NULL on error. </dd> <dt>int save_png(const char* filename, BITMAP* bmp, const RGB* pal)</dt> <dd> Save BITMAP to the file. Returns zero on success, non-zero on error. See <a href="http://alleg.sourceforge.net/onlinedocs/en/alleg010.html#save_bmp"><tt>save_bitmap</tt> </a> for details. Note that if the library is built in standalone mode, the saved PNG files will be uncompressed. See <a href="#libs">Supported additional libraries</a> section for details about this. The generated files have always 8 bits per sample, palette BITMAPs are stored as palette PNGs, 32 bit BITMAPs with alpha are saved as RGBA, all the others are saved in RGB format. </dd> <dt>int save_png_pf(PACKFILE* f, BITMAP* bmp, const RGB* pal)</dt> <dd> Saves PNG to an already open packfile. </dd> <dt>char* alpng_error_msg</dt> <dd> If an error occurs, this variable will contain string with the error description. </dd> </dl> <h3 xmlns="">PNG files in datafile</h3> <p xmlns=""> You can load PNG file into the datafile. Run Grabber, create new "Other" object, put "PNG" as a type and choose some name. Then Grab a PNG file into this object. In a program call <a href="#alpng_init">alpng_init</a> and <b>after</b> that load datafile. You can than access the BITMAP like any other image in the datafile: </p> <pre xmlns="">BITMAP* b = (BITMAP*) datafile[OBJECT_NAME].dat;</pre> <h3 xmlns="">List of tools for PNG optimization</h3> <p xmlns=""> This section lists tools which you can use to make your PNG files smaller. They are not related to AllegroPNG in any way, however I think such list can be useful for you. </p> <p xmlns=""> Best PNG optimizer is probably Ken Silverman's <a href="http://advsys.net/ken/utils.htm">PNGOUT</a>. It's freeware, closed source primary for Windows however some <a href="http://jonof.edgenetwork.org/index.php?p=kenutils">ports for Linux and MacOSX</a> exists. For Windows there is also GUI add-on called <a href="http://brh.numbera.com/software/pnggauntlet/">PNGGauntlet</a> written using NET Framework 1.1. There is also commercial version with Windows GUI: <a href="http://ardfry.com/pngoutwin/">PNGOUTWin</a>. Also plugin for the <a href="http://irfanview.com/">IrfanView</a> exists. </p> <p xmlns=""> <a href="http://entropymine.com/jason/pngrewrite/">Pngrewrite</a> optimizes palette PNGs. </p> <p xmlns=""> Others are <a href="http://www.cs.toronto.edu/~cosmin/pngtech/optipng/">OptiPNG</a>, <a href="http://pmt.sourceforge.net/pngcrush/">Pngcrush</a> and <a href="http://advancemame.sourceforge.net/comp-readme.html">AdvPNG</a>. </p> <h2 id="libs" xmlns="">Supported additional libraries</h2> <p xmlns=""> If you want to improve speed of this library or want to use compression for saving you can optionally use some library which implements deflate de/compression. Currently supported are the original <a href="http://zlib.net/">zlib</a> library and <a href="http://cryptopp.com/">Crypto++</a> library. </p> <h3 xmlns="">Benchmark suite</h3> <p xmlns=""> In the AllegroPNG Subversion repository is available <a href="http://alpng.svn.sourceforge.net/viewvc/alpng/benchmark/trunk/"> small benchmark suite</a> for comparing speed. </p> Generally is for loading the fastest version using original <a href="http://zlib.net/" xmlns="">zlib</a>, slowest standalone version. For saving is fastest the standalone version because it does not compress the file, otherwise <a href="http://zlib.net/" xmlns="">zlib</a> is faster than <a href="http://cryptopp.com/" xmlns="">Crypto++</a>. Note that on MinGW (gcc 3.4.2) is the <a href="http://cryptopp.com/" xmlns="">Crypto++</a> for some reason extremely slow. The <a href="http://tjaden.strangesoft.net/loadpng/" xmlns="">loadpng</a> library is of course always the fastest. <h2 xmlns="">Installation</h2> <h3 xmlns="">MinGW</h3> <p xmlns=""> Open command line window, make sure that GCC is on the path (test it by typing gcc -v, it should display GCC version). If you have NET Framework 2.0 runtime installed, run configure.exe and select MinGW as a compiler, otherwise run on the command line </p> <pre xmlns="">configure.bat mingw</pre> <p xmlns=""> Run configure.bat without parameters to see complete list of options. </p> <p xmlns=""> Then run: </p> <pre xmlns="">mingw32-make</pre> <p xmlns=""> and wait until the library and example are build. </p> <p xmlns=""> Copy the <tt>libalpng.a</tt> to the lib directory of your MinGW installation and <tt>src\alpng.h</tt> to the include directory of your MinGW installation. </p> <p xmlns=""> Don't forget to build your application with the -lalpng linker setting. </p> <p class="note" xmlns=""><em>Note: </em> For <a href="http://www.bloodshed.net/dev/">Dev-C++</a> and <a href="http://www.codeblocks.org/">Code::Blocks</a> there is always AllegroPNG devpak at <a href="http://devpaks.org/category.php?category=Allegro">devpaks.org</a>. </p> <h3 xmlns="">DJGPP</h3> <p xmlns=""> Follow the MinGW instructions, only run <tt>make</tt> instead of <tt>mingw32-make</tt>. </p> <h3 xmlns="">MS Visual C++</h3> <p xmlns=""> Open command line window, make sure that Visual C++ is on the path (test it by typing cl, it should display Visual C++ version). If you have NET Framework 2.0 runtime installed, run configure.exe and select MS Visual C++ as a compiler, otherwise run on the command line </p> <pre xmlns="">configure.bat msvc</pre> <p xmlns=""> Run configure.bat without parameters to see complete list of options. </p> <p xmlns=""> Then run: </p> <pre xmlns="">nmake</pre> <p xmlns=""> and wait until the library and example are build. </p> <p xmlns=""> Copy the <tt>alpng.lib</tt> to the lib directory of your Visual C++ installation and <tt>src\alpng.h</tt> to the include directory of your Visual C++ installation. </p> <p xmlns=""> Don't forget to link your application with the alpng.lib library. </p> <h3 xmlns="">Linux</h3> <p xmlns=""> Run: </p> <pre xmlns="">make</pre> <p xmlns=""> and wait until the library and example are build. You can also type </p> <pre xmlns="">./configure zlib</pre> <p xmlns=""> to build library which uses <a href="http://zlib.net/">zlib</a> or </p> <pre xmlns="">./configure crypto++</pre> <p xmlns=""> to build library which uses <a href="http://cryptopp.com/">Crypto++</a> or </p> <pre xmlns="">./configure</pre> <p xmlns=""> to revert back to the standalone version. </p> <p xmlns=""> Copy the <tt>libalpng.a</tt> to the lib directory of your system and <tt>src\alpng.h</tt> to the include directory of your system.. </p> <p xmlns=""> Don't forget to build your application with the -lalpng linker setting. </p> <h3 id="octree" xmlns="">Common</h3> <p xmlns=""> If you want to disable internal octree quantization and use <a href="http://alleg.sourceforge.net/">Allegro</a>'s <tt>generate_optimized_palette</tt> instead, just add <tt>-DALPNG_USE_ALLEGRO_QUANTIZATION</tt> to the <tt>CFLAGS</tt> environment variable before building the library. </p> <h2 xmlns="">Contact</h2> <p xmlns=""> Library written by Michal Molhanec. <script type="text/javascript"> <!-- var domain = "cent" + "rum.cz"; var name = "mol" +'soft'; var at = "@"; document.write("<p><a href='ma" +"ilto:" + name + '' + at + "" +domain +"'>" + 'Send email.' +"</a></p>"); //--> </script> <noscript> <p><a href="mailto:molsoft@NOSPAMcentrum.cz">Send email.</a></p> </noscript> <a href="http://molhanec.net/">Personal homepage.</a> </p> <p style="text-align:center"> <a href="http://sourceforge.net"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=164908&amp;type=2" width="125" height="37" border="0" alt="SourceForge.net Logo" /></a> </p> </div> </body> </html>