1
/*---------------------------------------------------------------------------
3
pngquant: RGBA -> RGBA-palette quantization program rwpng.h
5
---------------------------------------------------------------------------
7
Copyright (c) 1998-2000 Greg Roelofs. All rights reserved.
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
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:
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:
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.
30
---------------------------------------------------------------------------*/
38
# define MAX(a,b) ((a) > (b)? (a) : (b))
39
# define MIN(a,b) ((a) < (b)? (a) : (b))
43
# define Trace(x) {fprintf x ; fflush(stderr); fflush(stdout);}
48
typedef unsigned char uch;
49
typedef unsigned short ush;
50
typedef unsigned long ulg;
52
typedef struct _rwpng_color_struct {
58
typedef struct _mainprog_info {
60
ulg width; /* read/write */
61
ulg height; /* read/write */
62
ulg rowbytes; /* read */
63
void *png_ptr; /* read/write */
64
void *info_ptr; /* read/write */
65
rwpng_color palette[256]; /* write */
66
uch trans[256]; /* write */
67
uch *rgba_data; /* read */
68
uch *indexed_data; /* write */
69
uch **row_pointers; /* read/write */
70
jmp_buf jmpbuf; /* read/write */
71
int interlaced; /* read/write */
72
int channels; /* read (currently not used) */
73
int sample_depth; /* write */
74
int num_palette; /* write */
75
int num_trans; /* write */
76
int retval; /* read/write */
80
/* prototypes for public functions in rwpng.c */
82
void rwpng_version_info(void);
84
int rwpng_read_image(FILE *infile, mainprog_info *mainprog_ptr);
86
int rwpng_write_image_init(FILE *outfile, mainprog_info *mainprog_ptr);
88
int rwpng_write_image_whole(mainprog_info *mainprog_ptr);
90
int rwpng_write_image_row(mainprog_info *mainprog_ptr);
92
int rwpng_write_image_finish(mainprog_info *mainprog_ptr);