w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pngio.c
Go to the documentation of this file.
1 /*====================================================================*
2  - Copyright (C) 2001 Leptonica. All rights reserved.
3  - This software is distributed in the hope that it will be
4  - useful, but with NO WARRANTY OF ANY KIND.
5  - No author or distributor accepts responsibility to anyone for the
6  - consequences of using this software, or for whether it serves any
7  - particular purpose or works at all, unless he or she says so in
8  - writing. Everyone is granted permission to copy, modify and
9  - redistribute this source code, for commercial or non-commercial
10  - purposes, with the following restrictions: (1) the origin of this
11  - source code must not be misrepresented; (2) modified versions must
12  - be plainly marked as such; and (3) this notice may not be removed
13  - or altered from any source or modified source distribution.
14  *====================================================================*/
15 
16 /*
17  * pngio.c
18  *
19  * PIX *pixReadStreamPng()
20  * l_int32 pixWriteStreamPng()
21  *
22  * l_int32 readHeaderPng()
23  * l_int32 freadHeaderPng()
24  * l_int32 sreadHeaderPng()
25  *
26  *
27  * Documentation: libpng.txt and example.c
28  *
29  * On input (decompression from file), palette color images
30  * are read into an 8 bpp Pix with a colormap, and 24 bpp
31  * 3 component color images are read into a 32 bpp Pix with
32  * rgb samples. On output (compression to file), palette color
33  * images are written as 8 bpp with the colormap, and 32 bpp
34  * full color images are written compressed as a set of three
35  * 8 bpp (rgb) images.
36  */
37 
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 
42 #include "allheaders.h"
43 
44 #ifndef NO_CONSOLE_IO
45 #define DEBUG 0
46 #endif /* ~NO_CONSOLE_IO */
47 
48 
49 /*!
50  * pixReadStreamPng()
51  *
52  * Input: stream
53  * Return: pix, or null on error
54  *
55  * Usage notes:
56  * (1) If called from pixReadStream(), the stream is positioned
57  * at the beginning of the file.
58  * (2) To do sequential reads of png format images from a stream,
59  * use pixReadStreamPng()
60  */
61 PIX *
63 {
64 l_uint8 rval, gval, bval;
65 l_int32 i, j, k;
66 l_int32 wpl, d, spp, cindex;
67 l_uint32 png_transforms;
68 l_uint32 *data, *line, *ppixel;
69 int num_palette;
70 png_byte bit_depth, color_type, channels;
71 png_uint_32 w, h, rowbytes;
73 png_bytep rowptr;
74 png_bytep *row_pointers;
76 png_infop info_ptr, end_info;
77 png_colorp palette;
78 PIX *pix;
79 PIXCMAP *cmap;
80 
81  PROCNAME("pixReadStreamPng");
82 
83  if (!fp)
84  return (PIX *)ERROR_PTR("fp not defined", procName, NULL);
85  pix = NULL;
86 
87  /* Allocate the 3 data structures */
89  (png_voidp)NULL, NULL, NULL)) == NULL)
90  return (PIX *)ERROR_PTR("png_ptr not made", procName, NULL);
91 
92  if ((info_ptr = png_create_info_struct(png_ptr)) == NULL) {
94  return (PIX *)ERROR_PTR("info_ptr not made", procName, NULL);
95  }
96 
97  if ((end_info = png_create_info_struct(png_ptr)) == NULL) {
99  return (PIX *)ERROR_PTR("end_info not made", procName, NULL);
100  }
101 
102  /* Set up png setjmp error handling */
103  if (setjmp(png_jmpbuf(png_ptr))) {
104  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
105  return (PIX *)ERROR_PTR("internal png error", procName, NULL);
106  }
107 
109 
110  /* Set the transforms flags. Whatever you do here,
111  * DO NOT invert binary using PNG_TRANSFORM_INVERT_MONO!!
112  * To remove alpha channel, use PNG_TRANSFORM_STRIP_ALPHA
113  * To strip 16 --> 8 bit depth, use PNG_TRANSFORM_STRIP_16 */
114 #if 0 /* this does both */
116 #else /* this just strips alpha */
117  png_transforms = PNG_TRANSFORM_STRIP_ALPHA;
118 #endif
119 
120  /* Do it! */
121  png_read_png(png_ptr, info_ptr, png_transforms, NULL);
122 
123  row_pointers = png_get_rows(png_ptr, info_ptr);
124  w = png_get_image_width(png_ptr, info_ptr);
125  h = png_get_image_height(png_ptr, info_ptr);
126  bit_depth = png_get_bit_depth(png_ptr, info_ptr);
127  rowbytes = png_get_rowbytes(png_ptr, info_ptr);
128  color_type = png_get_color_type(png_ptr, info_ptr);
129  channels = png_get_channels(png_ptr, info_ptr);
130 
131  spp = channels;
132 
133  if (spp == 1)
134  d = bit_depth;
135  else if (spp == 2) {
136  d = 2 * bit_depth;
137  L_WARNING("there shouldn't be 2 spp!", procName);
138  }
139  else if (spp == 3)
140  d = 4 * bit_depth;
141  else { /* spp == 4 */
142  d = 4 * bit_depth;
143  L_WARNING("there shouldn't be 4 spp!", procName);
144  }
145 
146  /* Remove if/when this is implemented for all bit_depths */
147  if (spp == 3 && bit_depth != 8) {
148  fprintf(stderr, "Help: spp = 3 and depth = %d != 8\n!!", bit_depth);
149  return (PIX *)ERROR_PTR("not implemented for this depth",
150  procName, NULL);
151  }
152 
153  if (color_type == PNG_COLOR_TYPE_PALETTE ||
154  color_type == PNG_COLOR_MASK_PALETTE) { /* generate a colormap */
155  png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
156  cmap = pixcmapCreate(d); /* spp == 1 */
157  for (cindex = 0; cindex < num_palette; cindex++) {
158  rval = palette[cindex].red;
159  gval = palette[cindex].green;
160  bval = palette[cindex].blue;
161  pixcmapAddColor(cmap, rval, gval, bval);
162  }
163  }
164  else
165  cmap = NULL;
166 
167  if ((pix = pixCreate(w, h, d)) == NULL) {
168  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
169  return (PIX *)ERROR_PTR("pix not made", procName, NULL);
170  }
171  wpl = pixGetWpl(pix);
172  data = pixGetData(pix);
174 
175  if (spp == 1) { /* copy straight from buffer to pix */
176  for (i = 0; i < h; i++) {
177  line = data + i * wpl;
178  rowptr = row_pointers[i];
179  for (j = 0; j < rowbytes; j++) {
180  SET_DATA_BYTE(line, j, rowptr[j]);
181  }
182  }
183  }
184  else { /* spp == 3 */
185  for (i = 0; i < h; i++) {
186  ppixel = data + i * wpl;
187  rowptr = row_pointers[i];
188  for (j = k = 0; j < w; j++) {
189  SET_DATA_BYTE(ppixel, COLOR_RED, rowptr[k++]);
190  SET_DATA_BYTE(ppixel, COLOR_GREEN, rowptr[k++]);
191  SET_DATA_BYTE(ppixel, COLOR_BLUE, rowptr[k++]);
192  ppixel++;
193  }
194  }
195  }
196 
197 #if DEBUG
198  if (cmap) {
199  for (i = 0; i < 16; i++) {
200  fprintf(stderr, "[%d] = %d\n", i,
201  ((l_uint8 *)(cmap->array))[i]);
202  }
203  }
204 #endif /* DEBUG */
205 
206  /* If there is no colormap, PNG defines black = 0 and
207  * white = 1 by default for binary monochrome. Therefore,
208  * since we use the opposite definition, we must invert
209  * the image in either of these cases:
210  * (i) there is no colormap (default)
211  * (ii) there is a colormap which defines black to
212  * be 0 and white to be 1.
213  * We cannot use the PNG_TRANSFORM_INVERT_MONO flag
214  * because that flag (since version 1.0.9) inverts 8 bpp
215  * grayscale as well, which we don't want to do.
216  * (It also doesn't work if there is a colormap.)
217  * If there is a colormap that defines black = 1 and
218  * white = 0, we don't need to do anything.
219  *
220  * How do we check the polarity of the colormap?
221  * The colormap determines the values of black and
222  * white pixels in the following way:
223  * if black = 1 (255), white = 0
224  * 255, 255, 255, 0, 0, 0, 0, 0, 0
225  * if black = 0, white = 1 (255)
226  * 0, 0, 0, 0, 255, 255, 255, 0
227  * So we test the first byte to see if it is 0;
228  * if so, invert the data. */
229  if (d == 1 && (!cmap || (cmap && ((l_uint8 *)(cmap->array))[0] == 0x0))) {
230 /* fprintf(stderr, "Inverting binary data on png read\n"); */
231  pixInvert(pix, pix);
232  }
233 
236  pixSetXRes(pix, (l_int32)((l_float32)xres / 39.37 + 0.5)); /* to ppi */
237  pixSetYRes(pix, (l_int32)((l_float32)yres / 39.37 + 0.5)); /* to ppi */
238 
239  png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
240 
241  return pix;
242 }
243 
244 
245 /*!
246  * pixWriteStreamPng()
247  *
248  * Input: stream, pix
249  * Return: 0 if OK; 1 on error
250  *
251  * Usage notes:
252  * (1) If called from pixWriteStream(), the stream is positioned
253  * at the beginning of the file.
254  * (2) To do sequential writes of png format images to a stream,
255  * use pixWriteStreamPng().
256  */
257 l_int32
259  PIX *pix)
260 {
261 l_int32 i, j, k;
262 l_int32 wpl, d, cmflag;
263 l_int32 ncolors;
264 l_int32 *rmap, *gmap, *bmap;
265 l_uint32 *data, *ppixel;
266 png_byte bit_depth, color_type;
267 png_uint_32 w, h;
269 png_bytep *row_pointers;
270 png_bytep rowbuffer;
272 png_infop info_ptr;
273 png_colorp palette;
274 PIX *pixt;
275 PIXCMAP *cmap;
276 char *text;
277 
278  PROCNAME("pixWriteStreamPng");
279 
280  if (!fp)
281  return ERROR_INT("stream not open", procName, 1);
282  if (!pix)
283  return ERROR_INT("pix not defined", procName, 1);
284 
285  /* Allocate the 2 data structures */
287  (png_voidp)NULL, NULL, NULL)) == NULL)
288  return ERROR_INT("png_ptr not made", procName, 1);
289 
290  if ((info_ptr = png_create_info_struct(png_ptr)) == NULL) {
292  return ERROR_INT("info_ptr not made", procName, 1);
293  }
294 
295  /* Set up png setjmp error handling */
296  if (setjmp(png_jmpbuf(png_ptr))) {
297  png_destroy_write_struct(&png_ptr, &info_ptr);
298  return ERROR_INT("internal png error", procName, 1);
299  }
300 
302 
303  w = pixGetWidth(pix);
304  h = pixGetHeight(pix);
305  d = pixGetDepth(pix);
306  if ((cmap = pixGetColormap(pix)))
307  cmflag = 1;
308  else
309  cmflag = 0;
310  if (d == 32) {
311  bit_depth = 8;
312  color_type = PNG_COLOR_TYPE_RGB;
313  cmflag = 0; /* ignore if it exists */
314  }
315  else {
316  bit_depth = d;
317  color_type = PNG_COLOR_TYPE_GRAY;
318  }
319  if (cmflag)
320  color_type = PNG_COLOR_TYPE_PALETTE;
321 
322 #if DEBUG
323  fprintf(stderr, "cmflag = %d, bit_depth = %d, color_type = %d\n",
324  cmflag, bit_depth, color_type);
325 #endif /* DEBUG */
326 
327  png_set_IHDR(png_ptr, info_ptr, w, h, bit_depth, color_type,
330 
331  /* Store resolution in ppm, if known */
332  xres = (png_uint_32)(39.37 * (l_float32)pixGetXRes(pix) + 0.5);
333  yres = (png_uint_32)(39.37 * (l_float32)pixGetYRes(pix) + 0.5);
334  if ((xres == 0) || (yres == 0))
335  png_set_pHYs(png_ptr, info_ptr, 0, 0, PNG_RESOLUTION_UNKNOWN);
336  else
338 
339  if (cmflag) {
340  pixcmapToArrays(cmap, &rmap, &gmap, &bmap);
341  ncolors = pixcmapGetCount(cmap);
342 
343  /* Make and save the palette */
344  if ((palette = (png_colorp)(CALLOC(ncolors, sizeof(png_color))))
345  == NULL)
346  return ERROR_INT("palette not made", procName, 1);
347 
348  for (i = 0; i < ncolors; i++) {
349  palette[i].red = (png_byte)rmap[i];
350  palette[i].green = (png_byte)gmap[i];
351  palette[i].blue = (png_byte)bmap[i];
352  }
353 
354  png_set_PLTE(png_ptr, info_ptr, palette, (int)ncolors);
355 
356  FREE((void *)rmap);
357  FREE((void *)gmap);
358  FREE((void *)bmap);
359  }
360 
361  if ((text = pixGetText(pix))) {
362  png_text text_chunk;
364  text_chunk.key = "Comment";
365  text_chunk.text = text;
366  text_chunk.text_length = strlen(text);
367 #ifdef PNG_ITXT_SUPPORTED
368  text_chunk.itxt_length = 0;
369  text_chunk.lang = NULL;
370  text_chunk.lang_key = NULL;
371 #endif
372  png_set_text(png_ptr, info_ptr, &text_chunk, 1);
373  }
374  /* Write header and palette info */
375  png_write_info(png_ptr, info_ptr);
376 
377  if (d != 32) { /* not 24 bit color */
378  /* Generate a temporary pix with bytes swapped.
379  * For a binary image, there are two conditions in
380  * which you must first invert the data for writing png:
381  * (a) no colormap
382  * (b) colormap with BLACK set to 0
383  * png writes binary with BLACK = 0, unless contradicted
384  * by a colormap. If the colormap has BLACK = "1"
385  * (typ. about 255), do not invert the data. If there
386  * is no colormap, you must invert the data to store
387  * in default BLACK = 0 state. */
388  if (d == 1 &&
389  (!cmap || (cmap && ((l_uint8 *)(cmap->array))[0] == 0x0))) {
390  pixt = pixInvert(NULL, pix);
391  pixEndianByteSwap(pixt);
392  }
393  else
394  pixt = pixEndianByteSwapNew(pix);
395  if (!pixt) {
396  png_destroy_write_struct(&png_ptr, &info_ptr);
397  return ERROR_INT("pixt not made", procName, 1);
398  }
399 
400  /* Make and assign array of image row pointers */
401  if ((row_pointers = (png_bytep *)CALLOC(h, sizeof(png_bytep))) == NULL)
402  return ERROR_INT("row-pointers not made", procName, 1);
403  wpl = pixGetWpl(pixt);
404  data = pixGetData(pixt);
405  for (i = 0; i < h; i++)
406  row_pointers[i] = (png_bytep)(data + i * wpl);
407  png_set_rows(png_ptr, info_ptr, row_pointers);
408 
409  /* Transfer the data */
410  png_write_image(png_ptr, row_pointers);
411  png_write_end(png_ptr, info_ptr);
412 
413  if (cmflag)
414  FREE((void *)palette);
415  FREE((void *)row_pointers);
416  pixDestroy(&pixt);
417  png_destroy_write_struct(&png_ptr, &info_ptr);
418  return 0;
419  }
420 
421  /* 24 bit color; write a row at a time */
422  if ((rowbuffer = (png_bytep)CALLOC(w, 3)) == NULL)
423  return ERROR_INT("rowbuffer not made", procName, 1);
424  data = pixGetData(pix);
425  wpl = pixGetWpl(pix);
426  for (i = 0; i < h; i++) {
427  ppixel = data + i * wpl;
428  for (j = k = 0; j < w; j++) {
429  rowbuffer[k++] = GET_DATA_BYTE(ppixel, COLOR_RED);
430  rowbuffer[k++] = GET_DATA_BYTE(ppixel, COLOR_GREEN);
431  rowbuffer[k++] = GET_DATA_BYTE(ppixel, COLOR_BLUE);
432  ppixel++;
433  }
434 
435  png_write_rows(png_ptr, &rowbuffer, 1);
436  }
437 
438  png_write_end(png_ptr, info_ptr);
439 
440  if (cmflag)
441  FREE((void *)palette);
442  FREE((void *)rowbuffer);
443  png_destroy_write_struct(&png_ptr, &info_ptr);
444  return 0;
445 
446 }
447 
448 
449 /*!
450  * readHeaderPng()
451  *
452  * Input: filename
453  * &width (<return>)
454  * &height (<return>)
455  * &bpc (<return>, bits/component)
456  * &cpp (<return>, components/pixel)
457  * &cmap (<optional return>; input NULL to ignore)
458  * Return: 0 if OK, 1 on error
459  *
460  * Note: if there is a colormap, cmap is returned as 1; else 0.
461  */
462 l_int32
464  l_int32 *pwidth,
465  l_int32 *pheight,
466  l_int32 *pbpc,
467  l_int32 *pcpp,
468  l_int32 *pcmap)
469 {
470 l_int32 ret;
471 FILE *fp;
472 
473  PROCNAME("readHeaderPng");
474 
475  if (!filename)
476  return ERROR_INT("filename not defined", procName, 1);
477  if (!pwidth || !pheight || !pbpc || !pcpp)
478  return ERROR_INT("input ptr(s) not defined", procName, 1);
479  if ((fp = fopenReadStream(filename)) == NULL)
480  return ERROR_INT("image file not found", procName, 1);
481  ret = freadHeaderPng(fp, pwidth, pheight, pbpc, pcpp, pcmap);
482  fclose(fp);
483  return ret;
484 }
485 
486 
487 /*!
488  * freadHeaderPng()
489  *
490  * Input: stream
491  * &width (<return>)
492  * &height (<return>)
493  * &bpc (<return>, bits/component)
494  * &cpp (<return>, components/pixel)
495  * &cmap (<optional return>; input NULL to ignore)
496  * Return: 0 if OK, 1 on error
497  *
498  * Note: if there is a colormap, cmap is returned as 1; else 0.
499  */
500 l_int32
502  l_int32 *pwidth,
503  l_int32 *pheight,
504  l_int32 *pbpc,
505  l_int32 *pcpp,
506  l_int32 *pcmap)
507 {
509 l_uint8 *data;
510 
511  PROCNAME("freadHeaderPng");
512 
513  if (!fp)
514  return ERROR_INT("stream not defined", procName, 1);
515  if (!pwidth || !pheight || !pbpc || !pcpp)
516  return ERROR_INT("input ptr(s) not defined", procName, 1);
517 
519  if (nbytes < 40)
520  return ERROR_INT("file too small to be png", procName, 1);
521  if ((data = (l_uint8 *)CALLOC(40, sizeof(l_uint8))) == NULL)
522  return ERROR_INT("CALLOC fail for data", procName, 1);
523  fread(data, 40, 1, fp);
524  ret = sreadHeaderPng(data, pwidth, pheight, pbpc, pcpp, pcmap);
525  FREE((void *)data);
526  return ret;
527 }
528 
529 
530 /*!
531  * sreadHeaderPng()
532  *
533  * Input: data
534  * &width (<return>)
535  * &height (<return>)
536  * &bpc (<return>, bits/component)
537  * &cpp (<return>, components/pixel)
538  * &cmap (<optional return>; input NULL to ignore)
539  * Return: 0 if OK, 1 on error
540  *
541  * Note: if there is a colormap, cmap is returned as 1; else 0.
542  */
543 l_int32
545  l_int32 *pwidth,
546  l_int32 *pheight,
547  l_int32 *pbpc,
548  l_int32 *pcpp,
549  l_int32 *pcmap)
550 {
551 l_uint8 colortype, bpc;
553 l_uint16 *pshort;
554 l_uint32 *pword;
555 
556  PROCNAME("sreadHeaderPng");
557 
558  if (!data)
559  return ERROR_INT("data not defined", procName, 1);
560  if (!pwidth || !pheight || !pbpc || !pcpp)
561  return ERROR_INT("input ptr(s) not defined", procName, 1);
562  *pwidth = *pheight = *pbpc = *pcpp = 0;
563  if (pcmap)
564  *pcmap = 0;
565 
566  /* Check password */
567  if (data[0] != 137 || data[1] != 80 || data[2] != 78 ||
568  data[3] != 71 || data[4] != 13 || data[5] != 10 ||
569  data[6] != 26 || data[7] != 10)
570  return ERROR_INT("not a valid png file", procName, 1);
571 
572  pword = (l_uint32 *)data;
573  pshort = (l_uint16 *)data;
574  *pwidth = convertOnLittleEnd32(pword[4]);
575  *pheight = convertOnLittleEnd32(pword[5]);
576  twobytes = convertOnLittleEnd16(pshort[12]); /* contains depth/component */
577  /* and the color type */
578  colortype = twobytes & 0xff; /* color type */
579  bpc = twobytes >> 8; /* bits/component */
580  *pbpc = bpc;
581  if (colortype == 2) /* RGB */
582  *pcpp = 3;
583  else if (colortype == 6) /* RGBA */
584  *pcpp = 4;
585  else /* palette or gray */
586  *pcpp = 1;
587  if (pcmap) {
588  if (colortype & 1) /* palette: see png.h, PNG_COLOR_TYPE_... */
589  *pcmap = 1;
590  else
591  *pcmap = 0;
592  }
593 
594  return 0;
595 }
596 
#define text(a)
Definition: aptex-macros.h:925
#define GET_DATA_BYTE(pdata, n)
Definition: arrayaccess.h:98
#define SET_DATA_BYTE(pdata, n, val)
Definition: arrayaccess.h:106
static char gmap[128]
Definition: asciitopgm.c:19
l_int32 pixcmapGetCount(PIXCMAP *cmap)
Definition: colormap.c:279
PIXCMAP * pixcmapCreate(l_int32 depth)
Definition: colormap.c:68
l_int32 pixcmapAddColor(PIXCMAP *cmap, l_int32 rval, l_int32 gval, l_int32 bval)
Definition: colormap.c:162
l_int32 pixcmapToArrays(PIXCMAP *cmap, l_int32 **prmap, l_int32 **pgmap, l_int32 **pbmap)
Definition: colormap.c:616
int w
Definition: dviconv.c:26
int h
Definition: dviconv.c:9
#define fread
Definition: xxstdio.h:25
static halfword twobytes(void)
Definition: dvidvi.c:230
struct rect data
Definition: dvipdfm.c:64
#define PROCNAME(name)
Definition: environ.h:131
#define ERROR_PTR(a, b, c)
Definition: environ.h:132
unsigned short l_uint16
Definition: environ.h:31
unsigned int l_uint32
Definition: environ.h:33
unsigned char l_uint8
Definition: environ.h:29
#define L_WARNING(a, b)
Definition: environ.h:136
#define ERROR_INT(a, b, c)
Definition: environ.h:133
int l_int32
Definition: environ.h:32
float l_float32
Definition: environ.h:34
#define d(n)
Definition: gpos-common.c:151
const unsigned char FREE
Definition: image.cpp:34
unsigned nbytes
Definition: in_pcx.cpp:355
pix
Definition: in_pcx.cpp:383
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
void png_init_io(png_structrp png_ptr, png_FILE_p fp)
Definition: png.c:703
png_infop png_create_info_struct(png_const_structrp png_ptr)
Definition: png.c:354
void() png_write_rows(png_structrp png_ptr, png_bytepp row, png_uint_32 num_rows)
Definition: pngwrite.c:579
png_structp() png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
Definition: pngread.c:27
png_byte() png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:467
png_uint_32() png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:52
#define PNG_COLOR_TYPE_RGB
Definition: png.h:670
png_uint_32() png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:115
void() png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)
Definition: pngwrite.c:979
#define PNG_TRANSFORM_STRIP_ALPHA
Definition: png.h:834
void() png_read_png(png_structrp png_ptr, png_inforp info_ptr, int transforms, png_voidp params)
void() png_write_end(png_structrp png_ptr, png_inforp info_ptr)
Definition: pngwrite.c:358
png_structp() png_create_write_struct(png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn)
Definition: pngwrite.c:499
#define png_jmpbuf(png_ptr)
Definition: png.h:952
png_uint_32() png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette)
Definition: pngget.c:1012
void() png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr, png_bytepp row_pointers)
Definition: pngset.c:1546
#define PNG_RESOLUTION_UNKNOWN
Definition: png.h:710
#define PNG_TEXT_COMPRESSION_NONE
Definition: png.h:588
void() png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)
Definition: pngread.c:1011
png_uint_32() png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:137
#define PNG_RESOLUTION_METER
Definition: png.h:711
void() png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngwrite.c:192
void() png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, int interlace_method, int compression_method, int filter_method)
Definition: pngset.c:254
#define PNG_COLOR_MASK_PALETTE
Definition: png.h:663
png_uint_32() png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:61
png_byte() png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:79
void() png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_const_colorp palette, int num_palette)
Definition: pngset.c:572
#define PNG_FILTER_TYPE_BASE
Definition: png.h:682
size_t() png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:30
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:668
png_bytepp() png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:40
png_byte() png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
Definition: pngget.c:70
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:669
#define PNG_LIBPNG_VER_STRING
Definition: png.h:281
void() png_set_text(png_const_structrp png_ptr, png_inforp info_ptr, png_const_textp text_ptr, int num_text)
Definition: pngset.c:762
#define PNG_INTERLACE_NONE
Definition: png.h:687
void() png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)
Definition: pngset.c:556
#define PNG_TRANSFORM_STRIP_16
Definition: png.h:833
void() png_write_image(png_structrp png_ptr, png_bytepp image)
Definition: pngwrite.c:601
#define PNG_COMPRESSION_TYPE_BASE
Definition: png.h:678
unsigned int png_uint_32
Definition: pngconf.h:511
unsigned char png_byte
Definition: pngconf.h:481
png_byte * png_bytep
Definition: pngconf.h:579
void * png_voidp
Definition: pngconf.h:577
#define fclose
Definition: debug.h:100
static int ret
Definition: convert.c:72
#define fprintf
Definition: mendex.h:64
#define png_ptr(N)
Definition: image.h:99
#define CALLOC(t, n)
Definition: hash.c:21
l_uint32 * pixGetData(PIX *pix)
Definition: pix1.c:793
void pixDestroy(PIX **ppix)
Definition: pix1.c:225
l_int32 pixEndianByteSwap(PIX *pix)
Definition: pix2.c:1969
l_int32 pixSetYRes(PIX *pix, l_uint32 res)
Definition: pix1.c:602
l_int32 nbytesInFile(FILE *fp)
Definition: utils.c:841
PIX * pixEndianByteSwapNew(PIX *pixs)
Definition: pix2.c:1910
l_int32 pixSetXRes(PIX *pix, l_uint32 res)
Definition: pix1.c:553
l_int32 pixGetWpl(PIX *pix)
Definition: pix1.c:477
PIX * pixInvert(PIX *pixd, PIX *pixs)
Definition: pix2.c:1188
l_int32 pixGetDepth(PIX *pix)
Definition: pix1.c:449
char * pixGetText(PIX *pix)
Definition: pix1.c:658
l_uint32 pixGetXRes(PIX *pix)
Definition: pix1.c:529
l_int32 pixSetColormap(PIX *pix, PIXCMAP *colormap)
Definition: pix1.c:778
PIXCMAP * pixGetColormap(PIX *pix)
Definition: pix1.c:766
l_uint32 pixGetYRes(PIX *pix)
Definition: pix1.c:541
l_uint32 convertOnLittleEnd32(l_uint32 wordin)
Definition: utils.c:966
FILE * fopenReadStream(const char *filename)
Definition: utils.c:992
PIX * pixCreate(l_int32 width, l_int32 height, l_int32 depth)
Definition: pix1.c:90
l_int32 pixGetHeight(PIX *pix)
Definition: pix1.c:419
l_int32 pixGetWidth(PIX *pix)
Definition: pix1.c:389
l_uint16 convertOnLittleEnd16(l_uint16 shortin)
Definition: utils.c:931
int k
Definition: otp-parser.c:70
static int xres
Definition: pbmto4425.c:21
static int yres
Definition: pbmto4425.c:22
char * filename[256]
Definition: pbmtopk.c:46
@ COLOR_BLUE
Definition: pix.h:102
@ COLOR_RED
Definition: pix.h:100
@ COLOR_GREEN
Definition: pix.h:101
#define fp
l_int32 freadHeaderPng(FILE *fp, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbpc, l_int32 *pcpp, l_int32 *pcmap)
Definition: pngio.c:501
l_int32 pixWriteStreamPng(FILE *fp, PIX *pix)
Definition: pngio.c:258
PIX * pixReadStreamPng(FILE *fp)
Definition: pngio.c:62
l_int32 readHeaderPng(const char *filename, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbpc, l_int32 *pcpp, l_int32 *pcmap)
Definition: pngio.c:463
l_int32 sreadHeaderPng(const l_uint8 *data, l_int32 *pwidth, l_int32 *pheight, l_int32 *pbpc, l_int32 *pcpp, l_int32 *pcmap)
Definition: pngio.c:544
char line[1024]
Definition: process_score.c:29
#define gval(n)
Definition: ltable.h:14
Definition: pix.h:51
Definition: bdf.c:133
png_byte blue
Definition: png.h:482
png_byte red
Definition: png.h:480
png_byte green
Definition: png.h:481
png_charp text
Definition: png.h:570
png_charp lang_key
Definition: png.h:576
size_t text_length
Definition: png.h:572
png_charp lang
Definition: png.h:574
png_charp key
Definition: png.h:569
int compression
Definition: png.h:564
size_t itxt_length
Definition: png.h:573
#define FILE
Definition: t1stdio.h:34
int j
Definition: t4ht.c:1589
*job_name strlen((char *) job_name) - 4)
static unsigned short spp
Definition: tifftopnm.c:58
TT_CharMap cmap
Definition: ttf2pfb.c:163