1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
#ifndef PNGX_H_INCLUDED
#define PNGX_H_INCLUDED
#include <stdbool.h>
#include <png.h>
/* This includes the Zlib interface header file zlib.h because libpng uses
libz and some of the Zlib interface, e.g. the Z_DEFLATED constant,
is part of the libpng interface.
*/
#include "pm_c_util.h"
/* pngx is designed to be an extension of the PNG library to make using
the PNG library easier and cleaner.
*/
struct pngx_chroma {
float wx;
float wy;
float rx;
float ry;
float gx;
float gy;
float bx;
float by;
};
struct pngx_phys {
int x;
int y;
int unit;
};
struct pngx_text {
png_text * line;
unsigned int size;
};
struct pngx_plte {
png_color * palette;
unsigned int size;
};
struct pngx_trns {
png_byte * trans;
unsigned int numTrans;
png_color_16 transColor;
};
typedef enum {PNGX_READ, PNGX_WRITE} pngx_rw;
struct pngx {
png_structp png_ptr;
png_infop info_ptr;
pngx_rw rw;
png_uint_16 maxval;
unsigned int numPassesRequired;
/* The number of times we have to write the complete image to the
compressor. This is more than one when the compressor is set
up to do an interlaced format.
*/
bool infoPrepared;
/* png_write_info or png_read_info has been called, so libpng is in a
state in which things such as png_set_interlace_handling will work.
These functions use information in *png_ptr that is set by
png_XXX_info.
*/
};
void
pngx_create(struct pngx ** const pngxPP,
pngx_rw const rw,
jmp_buf * const jmpbufP);
void
pngx_destroy(struct pngx * const pngxP);
bool
pngx_chunkIsPresent(struct pngx * const pngxP,
uint32_t const chunkType);
unsigned int
pngx_bitDepth(struct pngx * const pngxP);
png_color_16
pngx_bkgd(struct pngx * const pngxP);
png_byte
pngx_colorType(struct pngx * const pngxP);
png_byte
pngx_filterType(struct pngx * const pngxP);
double
pngx_gama(struct pngx * const pngxP);
uint32_t
pngx_imageHeight(struct pngx * const pngxP);
uint32_t
pngx_imageWidth(struct pngx * const pngxP);
png_byte
pngx_interlaceType(struct pngx * const pngxP);
struct pngx_plte
pngx_plte(struct pngx * const pngxP);
png_color_8
pngx_sbit(struct pngx * const pngxP);
struct pngx_text
pngx_text(struct pngx * const pngxP);
png_time
pngx_time(struct pngx * const pngxP);
struct pngx_trns
pngx_trns(struct pngx * const pngxP);
uint32_t
pngx_xPixelsPerMeter(struct pngx * const pngxP);
uint32_t
pngx_yPixelsPerMeter(struct pngx * const pngxP);
float
pngx_pixelAspectRatio(struct pngx * const pngxP);
bool
pngx_pixelAspectRatioIsKnown(struct pngx * const pngxP);
void
pngx_removeChunk(struct pngx * const pngxP,
uint32_t const chunkType);
void
pngx_setBkgdPalette(struct pngx * const pngxP,
unsigned int const backgroundIndex);
void
pngx_setBkgdRgb(struct pngx * const pngxP,
png_color_16 const backgroundArg);
void
pngx_setChrm(struct pngx * const pngxP,
struct pngx_chroma const chroma);
typedef enum {
PNGX_PERCEPTUAL,
PNGX_RELATIVE_COLORIMETRIC,
PNGX_SATURATION,
PNGX_ABSOLUTE_COLORIMETRIC
} pngx_srgbIntent;
const char *
pngx_srgbIntentDesc(pngx_srgbIntent const srgbIntent);
void
pngx_setSrgb(struct pngx * const pngxP,
pngx_srgbIntent const srgbIntent);
void
pngx_setCompressionSize(struct pngx * const pngxP,
unsigned int const bufferSize);
void
pngx_setFilter(struct pngx * const pngxP,
int const filterSet);
void
pngx_setGama(struct pngx * const pngxP,
float const fileGamma);
void
pngx_setGamma(struct pngx * const pngxP,
float const displayGamma,
float const imageGamma);
void
pngx_setHist(struct pngx * const pngxP,
png_uint_16 * const histogram);
void
pngx_setIhdr(struct pngx * const pngxP,
unsigned int const width,
unsigned int const height,
unsigned int const bitDepth,
int const colorType,
int const interlaceMethod,
int const compressionMethod,
int const filterMethod);
void
pngx_setInterlaceHandling(struct pngx * const pngxP);
void
pngx_setInvalid(struct pngx * const pngxP);
void
pngx_setPacking(struct pngx * const pngxP);
void
pngx_setPhys(struct pngx * const pngxP,
struct pngx_phys const phys);
void
pngx_setPlte(struct pngx * const pngxP,
png_color * const palette,
unsigned int const paletteSize);
void
pngx_setSbit(struct pngx * const pngxP,
png_color_8 const sbit);
void
pngx_setShift(struct pngx * const pngxP,
png_color_8 const sigBitArg);
void
pngx_setSigBytes(struct pngx * const pngxP,
unsigned int const sigByteCt);
void
pngx_setTextKey(png_text * const textP,
const char * const key);
void
pngx_setTextLang(png_text * const textP,
const char * const language);
void
pngx_setTextLangKey(png_text * const textP,
const char * const key);
void
pngx_termText(png_text * const textP);
void
pngx_setText(struct pngx * const pngxP,
png_textp const textP,
unsigned int const count);
void
pngx_setTime(struct pngx * const pngxP,
time_t const timeArg);
void
pngx_setTrnsPalette(struct pngx * const pngxP,
const png_byte * const transPalette,
unsigned int const paletteSize);
void
pngx_setTrnsValue(struct pngx * const pngxP,
png_color_16 const transColorArg);
void
pngx_readInfo(struct pngx * const pngxP);
void
pngx_writeInfo(struct pngx * const pngxP);
void
pngx_readStart(struct pngx * const pngxP,
FILE * const ifP);
void
pngx_readRow(struct pngx * const pngxP,
png_byte * const rowBuf,
png_byte * const displayRow);
void
pngx_readImage(struct pngx * const pngxP,
png_byte ** const image);
void
pngx_writeRow(struct pngx * const pngxP,
const png_byte * const line);
void
pngx_writeImage(struct pngx * const pngxP,
png_byte ** const raster);
void
pngx_readEnd(struct pngx * const pngxP);
void
pngx_writeEnd(struct pngx * const pngxP);
#endif
|