lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /*--------------------------------------------------------------------------- |
| 2 | |
| 3 | rpng2 - progressive-model PNG display program readpng2.h |
| 4 | |
| 5 | --------------------------------------------------------------------------- |
| 6 | |
| 7 | Copyright (c) 1998-2001 Greg Roelofs. All rights reserved. |
| 8 | |
| 9 | This software is provided "as is," without warranty of any kind, |
| 10 | express or implied. In no event shall the author or contributors |
| 11 | be held liable for any damages arising in any way from the use of |
| 12 | this software. |
| 13 | |
| 14 | Permission is granted to anyone to use this software for any purpose, |
| 15 | including commercial applications, and to alter it and redistribute |
| 16 | it freely, subject to the following restrictions: |
| 17 | |
| 18 | 1. Redistributions of source code must retain the above copyright |
| 19 | notice, disclaimer, and this list of conditions. |
| 20 | 2. Redistributions in binary form must reproduce the above copyright |
| 21 | notice, disclaimer, and this list of conditions in the documenta- |
| 22 | tion and/or other materials provided with the distribution. |
| 23 | 3. All advertising materials mentioning features or use of this |
| 24 | software must display the following acknowledgment: |
| 25 | |
| 26 | This product includes software developed by Greg Roelofs |
| 27 | and contributors for the book, "PNG: The Definitive Guide," |
| 28 | published by O'Reilly and Associates. |
| 29 | |
| 30 | ---------------------------------------------------------------------------*/ |
| 31 | |
| 32 | #ifndef TRUE |
| 33 | # define TRUE 1 |
| 34 | # define FALSE 0 |
| 35 | #endif |
| 36 | |
| 37 | #ifndef MAX |
| 38 | # define MAX(a,b) ((a) > (b)? (a) : (b)) |
| 39 | # define MIN(a,b) ((a) < (b)? (a) : (b)) |
| 40 | #endif |
| 41 | |
| 42 | #ifdef DEBUG |
| 43 | # define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);} |
| 44 | #else |
| 45 | # define Trace(x) ; |
| 46 | #endif |
| 47 | |
| 48 | typedef unsigned char uch; |
| 49 | typedef unsigned short ush; |
| 50 | typedef unsigned long ulg; |
| 51 | |
| 52 | typedef struct _mainprog_info { |
| 53 | double display_exponent; |
| 54 | ulg width; |
| 55 | ulg height; |
| 56 | void *png_ptr; |
| 57 | void *info_ptr; |
| 58 | void (*mainprog_init)(void); |
| 59 | void (*mainprog_display_row)(ulg row_num); |
| 60 | void (*mainprog_finish_display)(void); |
| 61 | uch *image_data; |
| 62 | uch **row_pointers; |
| 63 | jmp_buf jmpbuf; |
| 64 | int passes; /* not used */ |
| 65 | int pass; |
| 66 | int rowbytes; |
| 67 | int channels; |
| 68 | int need_bgcolor; |
| 69 | #if (defined(__i386__) || defined(_M_IX86)) |
| 70 | int nommxfilters; |
| 71 | int nommxcombine; |
| 72 | int nommxinterlace; |
| 73 | #endif |
| 74 | int done; |
| 75 | uch bg_red; |
| 76 | uch bg_green; |
| 77 | uch bg_blue; |
| 78 | } mainprog_info; |
| 79 | |
| 80 | |
| 81 | /* prototypes for public functions in readpng2.c */ |
| 82 | |
| 83 | void readpng2_version_info(void); |
| 84 | |
| 85 | int readpng2_check_sig(uch *sig, int num); |
| 86 | |
| 87 | int readpng2_init(mainprog_info *mainprog_ptr); |
| 88 | |
| 89 | int readpng2_decode_data(mainprog_info *mainprog_ptr, uch *rawbuf, ulg length); |
| 90 | |
| 91 | void readpng2_cleanup(mainprog_info *mainprog_ptr); |