1*a67afe4dSAndroid Build Coastguard Worker /*--------------------------------------------------------------------------- 2*a67afe4dSAndroid Build Coastguard Worker 3*a67afe4dSAndroid Build Coastguard Worker wpng - simple PNG-writing program writepng.h 4*a67afe4dSAndroid Build Coastguard Worker 5*a67afe4dSAndroid Build Coastguard Worker --------------------------------------------------------------------------- 6*a67afe4dSAndroid Build Coastguard Worker 7*a67afe4dSAndroid Build Coastguard Worker Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. 8*a67afe4dSAndroid Build Coastguard Worker 9*a67afe4dSAndroid Build Coastguard Worker This software is provided "as is," without warranty of any kind, 10*a67afe4dSAndroid Build Coastguard Worker express or implied. In no event shall the author or contributors 11*a67afe4dSAndroid Build Coastguard Worker be held liable for any damages arising in any way from the use of 12*a67afe4dSAndroid Build Coastguard Worker this software. 13*a67afe4dSAndroid Build Coastguard Worker 14*a67afe4dSAndroid Build Coastguard Worker The contents of this file are DUAL-LICENSED. You may modify and/or 15*a67afe4dSAndroid Build Coastguard Worker redistribute this software according to the terms of one of the 16*a67afe4dSAndroid Build Coastguard Worker following two licenses (at your option): 17*a67afe4dSAndroid Build Coastguard Worker 18*a67afe4dSAndroid Build Coastguard Worker 19*a67afe4dSAndroid Build Coastguard Worker LICENSE 1 ("BSD-like with advertising clause"): 20*a67afe4dSAndroid Build Coastguard Worker 21*a67afe4dSAndroid Build Coastguard Worker Permission is granted to anyone to use this software for any purpose, 22*a67afe4dSAndroid Build Coastguard Worker including commercial applications, and to alter it and redistribute 23*a67afe4dSAndroid Build Coastguard Worker it freely, subject to the following restrictions: 24*a67afe4dSAndroid Build Coastguard Worker 25*a67afe4dSAndroid Build Coastguard Worker 1. Redistributions of source code must retain the above copyright 26*a67afe4dSAndroid Build Coastguard Worker notice, disclaimer, and this list of conditions. 27*a67afe4dSAndroid Build Coastguard Worker 2. Redistributions in binary form must reproduce the above copyright 28*a67afe4dSAndroid Build Coastguard Worker notice, disclaimer, and this list of conditions in the documenta- 29*a67afe4dSAndroid Build Coastguard Worker tion and/or other materials provided with the distribution. 30*a67afe4dSAndroid Build Coastguard Worker 3. All advertising materials mentioning features or use of this 31*a67afe4dSAndroid Build Coastguard Worker software must display the following acknowledgment: 32*a67afe4dSAndroid Build Coastguard Worker 33*a67afe4dSAndroid Build Coastguard Worker This product includes software developed by Greg Roelofs 34*a67afe4dSAndroid Build Coastguard Worker and contributors for the book, "PNG: The Definitive Guide," 35*a67afe4dSAndroid Build Coastguard Worker published by O'Reilly and Associates. 36*a67afe4dSAndroid Build Coastguard Worker 37*a67afe4dSAndroid Build Coastguard Worker 38*a67afe4dSAndroid Build Coastguard Worker LICENSE 2 (GNU GPL v2 or later): 39*a67afe4dSAndroid Build Coastguard Worker 40*a67afe4dSAndroid Build Coastguard Worker This program is free software; you can redistribute it and/or modify 41*a67afe4dSAndroid Build Coastguard Worker it under the terms of the GNU General Public License as published by 42*a67afe4dSAndroid Build Coastguard Worker the Free Software Foundation; either version 2 of the License, or 43*a67afe4dSAndroid Build Coastguard Worker (at your option) any later version. 44*a67afe4dSAndroid Build Coastguard Worker 45*a67afe4dSAndroid Build Coastguard Worker This program is distributed in the hope that it will be useful, 46*a67afe4dSAndroid Build Coastguard Worker but WITHOUT ANY WARRANTY; without even the implied warranty of 47*a67afe4dSAndroid Build Coastguard Worker MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 48*a67afe4dSAndroid Build Coastguard Worker GNU General Public License for more details. 49*a67afe4dSAndroid Build Coastguard Worker 50*a67afe4dSAndroid Build Coastguard Worker You should have received a copy of the GNU General Public License 51*a67afe4dSAndroid Build Coastguard Worker along with this program; if not, write to the Free Software Foundation, 52*a67afe4dSAndroid Build Coastguard Worker Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 53*a67afe4dSAndroid Build Coastguard Worker 54*a67afe4dSAndroid Build Coastguard Worker ---------------------------------------------------------------------------*/ 55*a67afe4dSAndroid Build Coastguard Worker 56*a67afe4dSAndroid Build Coastguard Worker #ifndef TRUE 57*a67afe4dSAndroid Build Coastguard Worker # define TRUE 1 58*a67afe4dSAndroid Build Coastguard Worker # define FALSE 0 59*a67afe4dSAndroid Build Coastguard Worker #endif 60*a67afe4dSAndroid Build Coastguard Worker 61*a67afe4dSAndroid Build Coastguard Worker #ifndef MAX 62*a67afe4dSAndroid Build Coastguard Worker # define MAX(a,b) ((a) > (b)? (a) : (b)) 63*a67afe4dSAndroid Build Coastguard Worker # define MIN(a,b) ((a) < (b)? (a) : (b)) 64*a67afe4dSAndroid Build Coastguard Worker #endif 65*a67afe4dSAndroid Build Coastguard Worker 66*a67afe4dSAndroid Build Coastguard Worker #ifdef DEBUG 67*a67afe4dSAndroid Build Coastguard Worker # define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} 68*a67afe4dSAndroid Build Coastguard Worker #else 69*a67afe4dSAndroid Build Coastguard Worker # define Trace(x) ; 70*a67afe4dSAndroid Build Coastguard Worker #endif 71*a67afe4dSAndroid Build Coastguard Worker 72*a67afe4dSAndroid Build Coastguard Worker #define TEXT_TITLE 0x01 73*a67afe4dSAndroid Build Coastguard Worker #define TEXT_AUTHOR 0x02 74*a67afe4dSAndroid Build Coastguard Worker #define TEXT_DESC 0x04 75*a67afe4dSAndroid Build Coastguard Worker #define TEXT_COPY 0x08 76*a67afe4dSAndroid Build Coastguard Worker #define TEXT_EMAIL 0x10 77*a67afe4dSAndroid Build Coastguard Worker #define TEXT_URL 0x20 78*a67afe4dSAndroid Build Coastguard Worker 79*a67afe4dSAndroid Build Coastguard Worker #define TEXT_TITLE_OFFSET 0 80*a67afe4dSAndroid Build Coastguard Worker #define TEXT_AUTHOR_OFFSET 72 81*a67afe4dSAndroid Build Coastguard Worker #define TEXT_COPY_OFFSET (2*72) 82*a67afe4dSAndroid Build Coastguard Worker #define TEXT_EMAIL_OFFSET (3*72) 83*a67afe4dSAndroid Build Coastguard Worker #define TEXT_URL_OFFSET (4*72) 84*a67afe4dSAndroid Build Coastguard Worker #define TEXT_DESC_OFFSET (5*72) 85*a67afe4dSAndroid Build Coastguard Worker 86*a67afe4dSAndroid Build Coastguard Worker typedef unsigned char uch; 87*a67afe4dSAndroid Build Coastguard Worker typedef unsigned short ush; 88*a67afe4dSAndroid Build Coastguard Worker typedef unsigned long ulg; 89*a67afe4dSAndroid Build Coastguard Worker 90*a67afe4dSAndroid Build Coastguard Worker typedef struct _mainprog_info { 91*a67afe4dSAndroid Build Coastguard Worker double gamma; 92*a67afe4dSAndroid Build Coastguard Worker long width; 93*a67afe4dSAndroid Build Coastguard Worker long height; 94*a67afe4dSAndroid Build Coastguard Worker time_t modtime; 95*a67afe4dSAndroid Build Coastguard Worker FILE *infile; 96*a67afe4dSAndroid Build Coastguard Worker FILE *outfile; 97*a67afe4dSAndroid Build Coastguard Worker void *png_ptr; 98*a67afe4dSAndroid Build Coastguard Worker void *info_ptr; 99*a67afe4dSAndroid Build Coastguard Worker uch *image_data; 100*a67afe4dSAndroid Build Coastguard Worker uch **row_pointers; 101*a67afe4dSAndroid Build Coastguard Worker char *title; 102*a67afe4dSAndroid Build Coastguard Worker char *author; 103*a67afe4dSAndroid Build Coastguard Worker char *desc; 104*a67afe4dSAndroid Build Coastguard Worker char *copyright; 105*a67afe4dSAndroid Build Coastguard Worker char *email; 106*a67afe4dSAndroid Build Coastguard Worker char *url; 107*a67afe4dSAndroid Build Coastguard Worker int filter; /* command-line-filter flag, not PNG row filter! */ 108*a67afe4dSAndroid Build Coastguard Worker int pnmtype; 109*a67afe4dSAndroid Build Coastguard Worker int sample_depth; 110*a67afe4dSAndroid Build Coastguard Worker int interlaced; 111*a67afe4dSAndroid Build Coastguard Worker int have_bg; 112*a67afe4dSAndroid Build Coastguard Worker int have_time; 113*a67afe4dSAndroid Build Coastguard Worker int have_text; 114*a67afe4dSAndroid Build Coastguard Worker jmp_buf jmpbuf; 115*a67afe4dSAndroid Build Coastguard Worker uch bg_red; 116*a67afe4dSAndroid Build Coastguard Worker uch bg_green; 117*a67afe4dSAndroid Build Coastguard Worker uch bg_blue; 118*a67afe4dSAndroid Build Coastguard Worker } mainprog_info; 119*a67afe4dSAndroid Build Coastguard Worker 120*a67afe4dSAndroid Build Coastguard Worker 121*a67afe4dSAndroid Build Coastguard Worker /* prototypes for public functions in writepng.c */ 122*a67afe4dSAndroid Build Coastguard Worker 123*a67afe4dSAndroid Build Coastguard Worker void writepng_version_info(void); 124*a67afe4dSAndroid Build Coastguard Worker 125*a67afe4dSAndroid Build Coastguard Worker int writepng_init(mainprog_info *mainprog_ptr); 126*a67afe4dSAndroid Build Coastguard Worker 127*a67afe4dSAndroid Build Coastguard Worker int writepng_encode_image(mainprog_info *mainprog_ptr); 128*a67afe4dSAndroid Build Coastguard Worker 129*a67afe4dSAndroid Build Coastguard Worker int writepng_encode_row(mainprog_info *mainprog_ptr); 130*a67afe4dSAndroid Build Coastguard Worker 131*a67afe4dSAndroid Build Coastguard Worker int writepng_encode_finish(mainprog_info *mainprog_ptr); 132*a67afe4dSAndroid Build Coastguard Worker 133*a67afe4dSAndroid Build Coastguard Worker void writepng_cleanup(mainprog_info *mainprog_ptr); 134