00001 /*--------------------------------------------------------------------------- 00002 00003 wpng - simple PNG-writing program writepng.h 00004 00005 --------------------------------------------------------------------------- 00006 00007 Copyright (c) 1998-2000 Greg Roelofs. All rights reserved. 00008 00009 This software is provided "as is," without warranty of any kind, 00010 express or implied. In no event shall the author or contributors 00011 be held liable for any damages arising in any way from the use of 00012 this software. 00013 00014 Permission is granted to anyone to use this software for any purpose, 00015 including commercial applications, and to alter it and redistribute 00016 it freely, subject to the following restrictions: 00017 00018 1. Redistributions of source code must retain the above copyright 00019 notice, disclaimer, and this list of conditions. 00020 2. Redistributions in binary form must reproduce the above copyright 00021 notice, disclaimer, and this list of conditions in the documenta- 00022 tion and/or other materials provided with the distribution. 00023 3. All advertising materials mentioning features or use of this 00024 software must display the following acknowledgment: 00025 00026 This product includes software developed by Greg Roelofs 00027 and contributors for the book, "PNG: The Definitive Guide," 00028 published by O'Reilly and Associates. 00029 00030 ---------------------------------------------------------------------------*/ 00031 00032 #ifndef TRUE 00033 # define TRUE 1 00034 # define FALSE 0 00035 #endif 00036 00037 #ifndef MAX 00038 # define MAX(a,b) ((a) > (b)? (a) : (b)) 00039 # define MIN(a,b) ((a) < (b)? (a) : (b)) 00040 #endif 00041 00042 #ifdef DEBUG 00043 # define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} 00044 #else 00045 # define Trace(x) ; 00046 #endif 00047 00048 #define TEXT_TITLE 0x01 00049 #define TEXT_AUTHOR 0x02 00050 #define TEXT_DESC 0x04 00051 #define TEXT_COPY 0x08 00052 #define TEXT_EMAIL 0x10 00053 #define TEXT_URL 0x20 00054 00055 #define TEXT_TITLE_OFFSET 0 00056 #define TEXT_AUTHOR_OFFSET 72 00057 #define TEXT_COPY_OFFSET (2*72) 00058 #define TEXT_EMAIL_OFFSET (3*72) 00059 #define TEXT_URL_OFFSET (4*72) 00060 #define TEXT_DESC_OFFSET (5*72) 00061 00062 typedef unsigned char uch; 00063 typedef unsigned short ush; 00064 typedef unsigned long ulg; 00065 00066 typedef struct _mainprog_info { 00067 double gamma; 00068 long width; 00069 long height; 00070 time_t modtime; 00071 FILE *infile; 00072 FILE *outfile; 00073 void *png_ptr; 00074 void *info_ptr; 00075 uch *image_data; 00076 uch **row_pointers; 00077 char *title; 00078 char *author; 00079 char *desc; 00080 char *copyright; 00081 char *email; 00082 char *url; 00083 int filter; /* command-line-filter flag, not PNG row filter! */ 00084 int pnmtype; 00085 int sample_depth; 00086 int interlaced; 00087 int have_bg; 00088 int have_time; 00089 int have_text; 00090 jmp_buf jmpbuf; 00091 uch bg_red; 00092 uch bg_green; 00093 uch bg_blue; 00094 } mainprog_info; 00095 00096 00097 /* prototypes for public functions in writepng.c */ 00098 00099 void writepng_version_info(void); 00100 00101 int writepng_init(mainprog_info *mainprog_ptr); 00102 00103 int writepng_encode_image(mainprog_info *mainprog_ptr); 00104 00105 int writepng_encode_row(mainprog_info *mainprog_ptr); 00106 00107 int writepng_encode_finish(mainprog_info *mainprog_ptr); 00108 00109 void writepng_cleanup(mainprog_info *mainprog_ptr);