671242f350d172e106580348e24bab66b0d7e6a5vboxsync/*---------------------------------------------------------------------------
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync wpng - simple PNG-writing program writepng.h
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync ---------------------------------------------------------------------------
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync This software is provided "as is," without warranty of any kind,
671242f350d172e106580348e24bab66b0d7e6a5vboxsync express or implied. In no event shall the author or contributors
671242f350d172e106580348e24bab66b0d7e6a5vboxsync be held liable for any damages arising in any way from the use of
671242f350d172e106580348e24bab66b0d7e6a5vboxsync this software.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync Permission is granted to anyone to use this software for any purpose,
671242f350d172e106580348e24bab66b0d7e6a5vboxsync including commercial applications, and to alter it and redistribute
671242f350d172e106580348e24bab66b0d7e6a5vboxsync it freely, subject to the following restrictions:
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync 1. Redistributions of source code must retain the above copyright
671242f350d172e106580348e24bab66b0d7e6a5vboxsync notice, disclaimer, and this list of conditions.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync 2. Redistributions in binary form must reproduce the above copyright
671242f350d172e106580348e24bab66b0d7e6a5vboxsync notice, disclaimer, and this list of conditions in the documenta-
671242f350d172e106580348e24bab66b0d7e6a5vboxsync tion and/or other materials provided with the distribution.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync 3. All advertising materials mentioning features or use of this
671242f350d172e106580348e24bab66b0d7e6a5vboxsync software must display the following acknowledgment:
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync This product includes software developed by Greg Roelofs
671242f350d172e106580348e24bab66b0d7e6a5vboxsync and contributors for the book, "PNG: The Definitive Guide,"
671242f350d172e106580348e24bab66b0d7e6a5vboxsync published by O'Reilly and Associates.
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync ---------------------------------------------------------------------------*/
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#ifndef TRUE
671242f350d172e106580348e24bab66b0d7e6a5vboxsync# define TRUE 1
671242f350d172e106580348e24bab66b0d7e6a5vboxsync# define FALSE 0
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#endif
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#ifndef MAX
671242f350d172e106580348e24bab66b0d7e6a5vboxsync# define MAX(a,b) ((a) > (b)? (a) : (b))
671242f350d172e106580348e24bab66b0d7e6a5vboxsync# define MIN(a,b) ((a) < (b)? (a) : (b))
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#endif
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#ifdef DEBUG
671242f350d172e106580348e24bab66b0d7e6a5vboxsync# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);}
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#else
671242f350d172e106580348e24bab66b0d7e6a5vboxsync# define Trace(x) ;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#endif
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_TITLE 0x01
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_AUTHOR 0x02
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_DESC 0x04
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_COPY 0x08
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_EMAIL 0x10
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_URL 0x20
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_TITLE_OFFSET 0
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_AUTHOR_OFFSET 72
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_COPY_OFFSET (2*72)
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_EMAIL_OFFSET (3*72)
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_URL_OFFSET (4*72)
671242f350d172e106580348e24bab66b0d7e6a5vboxsync#define TEXT_DESC_OFFSET (5*72)
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsynctypedef unsigned char uch;
671242f350d172e106580348e24bab66b0d7e6a5vboxsynctypedef unsigned short ush;
671242f350d172e106580348e24bab66b0d7e6a5vboxsynctypedef unsigned long ulg;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsynctypedef struct _mainprog_info {
671242f350d172e106580348e24bab66b0d7e6a5vboxsync double gamma;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync long width;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync long height;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync time_t modtime;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync FILE *infile;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync FILE *outfile;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync void *png_ptr;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync void *info_ptr;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync uch *image_data;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync uch **row_pointers;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync char *title;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync char *author;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync char *desc;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync char *copyright;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync char *email;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync char *url;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync int filter; /* command-line-filter flag, not PNG row filter! */
671242f350d172e106580348e24bab66b0d7e6a5vboxsync int pnmtype;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync int sample_depth;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync int interlaced;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync int have_bg;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync int have_time;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync int have_text;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync jmp_buf jmpbuf;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync uch bg_red;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync uch bg_green;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync uch bg_blue;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync} mainprog_info;
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsync/* prototypes for public functions in writepng.c */
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncvoid writepng_version_info(void);
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncint writepng_init(mainprog_info *mainprog_ptr);
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncint writepng_encode_image(mainprog_info *mainprog_ptr);
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncint writepng_encode_row(mainprog_info *mainprog_ptr);
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncint writepng_encode_finish(mainprog_info *mainprog_ptr);
671242f350d172e106580348e24bab66b0d7e6a5vboxsync
671242f350d172e106580348e24bab66b0d7e6a5vboxsyncvoid writepng_cleanup(mainprog_info *mainprog_ptr);