Debian Codegraph @

converter/other/pngx.h

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