xref: /aosp_15_r20/external/libpng/contrib/gregbook/readpng2.h (revision a67afe4df73cf47866eedc69947994b8ff839aba)
1*a67afe4dSAndroid Build Coastguard Worker /*---------------------------------------------------------------------------
2*a67afe4dSAndroid Build Coastguard Worker 
3*a67afe4dSAndroid Build Coastguard Worker    rpng2 - progressive-model PNG display program                 readpng2.h
4*a67afe4dSAndroid Build Coastguard Worker 
5*a67afe4dSAndroid Build Coastguard Worker   ---------------------------------------------------------------------------
6*a67afe4dSAndroid Build Coastguard Worker 
7*a67afe4dSAndroid Build Coastguard Worker       Copyright (c) 1998-2008 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 enum rpng2_states {
73*a67afe4dSAndroid Build Coastguard Worker     kPreInit = 0,
74*a67afe4dSAndroid Build Coastguard Worker     kWindowInit,
75*a67afe4dSAndroid Build Coastguard Worker     kDone
76*a67afe4dSAndroid Build Coastguard Worker };
77*a67afe4dSAndroid Build Coastguard Worker 
78*a67afe4dSAndroid Build Coastguard Worker typedef unsigned char   uch;
79*a67afe4dSAndroid Build Coastguard Worker typedef unsigned short  ush;
80*a67afe4dSAndroid Build Coastguard Worker typedef unsigned long   ulg;
81*a67afe4dSAndroid Build Coastguard Worker 
82*a67afe4dSAndroid Build Coastguard Worker typedef struct _mainprog_info {
83*a67afe4dSAndroid Build Coastguard Worker     double display_exponent;
84*a67afe4dSAndroid Build Coastguard Worker     ulg width;
85*a67afe4dSAndroid Build Coastguard Worker     ulg height;
86*a67afe4dSAndroid Build Coastguard Worker     void *png_ptr;
87*a67afe4dSAndroid Build Coastguard Worker     void *info_ptr;
88*a67afe4dSAndroid Build Coastguard Worker     void (*mainprog_init)(void);
89*a67afe4dSAndroid Build Coastguard Worker     void (*mainprog_display_row)(ulg row_num);
90*a67afe4dSAndroid Build Coastguard Worker     void (*mainprog_finish_display)(void);
91*a67afe4dSAndroid Build Coastguard Worker     uch *image_data;
92*a67afe4dSAndroid Build Coastguard Worker     uch **row_pointers;
93*a67afe4dSAndroid Build Coastguard Worker     jmp_buf jmpbuf;
94*a67afe4dSAndroid Build Coastguard Worker     int passes;              /* not used */
95*a67afe4dSAndroid Build Coastguard Worker     int pass;
96*a67afe4dSAndroid Build Coastguard Worker     int rowbytes;
97*a67afe4dSAndroid Build Coastguard Worker     int channels;
98*a67afe4dSAndroid Build Coastguard Worker     int need_bgcolor;
99*a67afe4dSAndroid Build Coastguard Worker     int state;
100*a67afe4dSAndroid Build Coastguard Worker     uch bg_red;
101*a67afe4dSAndroid Build Coastguard Worker     uch bg_green;
102*a67afe4dSAndroid Build Coastguard Worker     uch bg_blue;
103*a67afe4dSAndroid Build Coastguard Worker } mainprog_info;
104*a67afe4dSAndroid Build Coastguard Worker 
105*a67afe4dSAndroid Build Coastguard Worker 
106*a67afe4dSAndroid Build Coastguard Worker /* prototypes for public functions in readpng2.c */
107*a67afe4dSAndroid Build Coastguard Worker 
108*a67afe4dSAndroid Build Coastguard Worker void readpng2_version_info(void);
109*a67afe4dSAndroid Build Coastguard Worker 
110*a67afe4dSAndroid Build Coastguard Worker int readpng2_check_sig(uch *sig, int num);
111*a67afe4dSAndroid Build Coastguard Worker 
112*a67afe4dSAndroid Build Coastguard Worker int readpng2_init(mainprog_info *mainprog_ptr);
113*a67afe4dSAndroid Build Coastguard Worker 
114*a67afe4dSAndroid Build Coastguard Worker int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length);
115*a67afe4dSAndroid Build Coastguard Worker 
116*a67afe4dSAndroid Build Coastguard Worker void readpng2_cleanup(mainprog_info *mainprog_ptr);
117