Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 111 lines (88 sloc) 3.294 kb
4507aff Hello World
porneL authored
1 /*---------------------------------------------------------------------------
2
3 pngquant: RGBA -> RGBA-palette quantization program rwpng.h
4
5 ---------------------------------------------------------------------------
6
7 Copyright (c) 1998-2000 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
af5136e @pornel Type-safe, although slightly bogus, error codes.
authored
48 typedef enum {
49 SUCCESS = 0,
50 READ_ERROR = 2,
51 TOO_MANY_COLORS = 5,
52 NOT_OVERWRITING_ERROR = 15,
53 CANT_WRITE_ERROR = 16,
54 OUT_OF_MEMORY_ERROR = 17,
55 PNG_OUT_OF_MEMORY_ERROR = 24,
56 INIT_OUT_OF_MEMORY_ERROR = 34,
57 INTERNAL_LOGIC_ERROR = 18,
58 BAD_SIGNATURE_ERROR = 21,
59 LIBPNG_FATAL_ERROR = 25,
60 LIBPNG_INIT_ERROR = 35,
61 LIBPNG_WRITE_ERROR = 55,
62 LIBPNG_WRITE_WHOLE_ERROR = 45,
63 } pngquant_error;
64
b155880 @pornel Separated mainprog_info into read_info and write_info
authored
65 typedef struct {
a652ce7 @pornel Trimmed rwpng structs
authored
66 jmp_buf jmpbuf;
67 png_uint_32 width;
68 png_uint_32 height;
69 png_uint_32 rowbytes;
4507aff Hello World
porneL authored
70 double gamma;
a652ce7 @pornel Trimmed rwpng structs
authored
71 int interlaced;
72 unsigned char *rgba_data;
73 unsigned char **row_pointers;
b155880 @pornel Separated mainprog_info into read_info and write_info
authored
74 } read_info;
75
76 typedef struct {
a652ce7 @pornel Trimmed rwpng structs
authored
77 jmp_buf jmpbuf;
78 void *png_ptr;
79 void *info_ptr;
80 png_uint_32 width;
81 png_uint_32 height;
b155880 @pornel Separated mainprog_info into read_info and write_info
authored
82 double gamma;
a652ce7 @pornel Trimmed rwpng structs
authored
83 int interlaced;
84 int num_palette;
85 int num_trans;
86 png_color palette[256];
87 unsigned char trans[256];
88 unsigned char *indexed_data;
89 unsigned char **row_pointers;
b155880 @pornel Separated mainprog_info into read_info and write_info
authored
90 } write_info;
4507aff Hello World
porneL authored
91
a652ce7 @pornel Trimmed rwpng structs
authored
92 typedef union {
93 jmp_buf jmpbuf;
94 read_info read;
95 write_info write;
96 } read_or_write_info;
4507aff Hello World
porneL authored
97
98 /* prototypes for public functions in rwpng.c */
99
100 void rwpng_version_info(void);
101
ff6a38f @pornel Stricter rwpng_ function prototypes
authored
102 pngquant_error rwpng_read_image(FILE *infile, read_info *mainprog_ptr);
4507aff Hello World
porneL authored
103
ff6a38f @pornel Stricter rwpng_ function prototypes
authored
104 pngquant_error rwpng_write_image_init(FILE *outfile, write_info *mainprog_ptr);
4507aff Hello World
porneL authored
105
ff6a38f @pornel Stricter rwpng_ function prototypes
authored
106 pngquant_error rwpng_write_image_whole(write_info *mainprog_ptr);
4507aff Hello World
porneL authored
107
b155880 @pornel Separated mainprog_info into read_info and write_info
authored
108 int rwpng_write_image_row(write_info *mainprog_ptr);
4507aff Hello World
porneL authored
109
b155880 @pornel Separated mainprog_info into read_info and write_info
authored
110 int rwpng_write_image_finish(write_info *mainprog_ptr);
Something went wrong with that request. Please try again.