/****************************************************************************** * * * * * Copyright (C) 1997-2004 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * * --------------------------------------------------------------------------- * * The Portable Network Graphic format is an ISO Standard. * Most of the code below was donated by Bernhard Ristow. */ #ifndef png_jmpbuf # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf) #endif #define ALL_STATIC #include <../libpng/png.h> #include #include #include #include #include "pngenc.h" #include "message.h" #undef jmpbuf static void user_error_fn(png_structp, png_const_charp error_msg) { err("%s\n", error_msg); } static void user_warning_fn(png_structp, png_const_charp warning_msg) { err("%s\n", warning_msg); } PngEncoder::PngEncoder(Byte *rawBytes, Color *p, int w, int h, Byte d, int t) : data(rawBytes), palette(p), width(w), height(h), depth(d), transIndex(t) { numPixels = w*h; dataPtr = data; } PngEncoder::~PngEncoder() { } void PngEncoder::write(const char *name) { FILE * file = NULL; unsigned char ** rows = 0; unsigned char * cmap = 0; short numOfColors = (1<