COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
pngtrans.c File Reference
#include "pngpriv.h"
Include dependency graph for pngtrans.c:

Functions

void png_set_bgr (png_structrp png_ptr)
 
void png_set_swap (png_structrp png_ptr)
 
void png_set_packing (png_structrp png_ptr)
 
void png_set_packswap (png_structrp png_ptr)
 
void png_set_shift (png_structrp png_ptr, png_const_color_8p true_bits)
 
int png_set_interlace_handling (png_structrp png_ptr)
 
void png_set_filler (png_structrp png_ptr, png_uint_32 filler, int filler_loc)
 
void png_set_add_alpha (png_structrp png_ptr, png_uint_32 filler, int filler_loc)
 
void png_set_swap_alpha (png_structrp png_ptr)
 
void png_set_invert_alpha (png_structrp png_ptr)
 
void png_set_invert_mono (png_structrp png_ptr)
 
void png_do_invert (png_row_infop row_info, png_bytep row)
 
void png_do_swap (png_row_infop row_info, png_bytep row)
 
void png_do_packswap (png_row_infop row_info, png_bytep row)
 
void png_do_strip_channel (png_row_infop row_info, png_bytep row, int at_start)
 
void png_do_bgr (png_row_infop row_info, png_bytep row)
 
void png_do_check_palette_indexes (png_structrp png_ptr, png_row_infop row_info)
 
void png_set_user_transform_info (png_structrp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels)
 
png_voidp png_get_user_transform_ptr (png_const_structrp png_ptr)
 
png_uint_32 png_get_current_row_number (png_const_structrp png_ptr)
 
png_byte png_get_current_pass_number (png_const_structrp png_ptr)
 

Variables

static const png_byte onebppswaptable [256]
 
static const png_byte twobppswaptable [256]
 
static const png_byte fourbppswaptable [256]
 

Function Documentation

void png_set_bgr ( png_structrp  png_ptr)
22 {
23  png_debug(1, "in png_set_bgr");
24 
25  if (png_ptr == NULL)
26  return;
27 
28  png_ptr->transformations |= PNG_BGR;
29 }
#define PNG_BGR
Definition: pngpriv.h:560
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 transformations
Definition: pngstruct.h:181
void png_set_swap ( png_structrp  png_ptr)
36 {
37  png_debug(1, "in png_set_swap");
38 
39  if (png_ptr == NULL)
40  return;
41 
42  if (png_ptr->bit_depth == 16)
43  png_ptr->transformations |= PNG_SWAP_BYTES;
44 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_SWAP_BYTES
Definition: pngpriv.h:564
png_byte bit_depth
Definition: pngstruct.h:253
png_uint_32 transformations
Definition: pngstruct.h:181
void png_set_packing ( png_structrp  png_ptr)
51 {
52  png_debug(1, "in png_set_packing");
53 
54  if (png_ptr == NULL)
55  return;
56 
57  if (png_ptr->bit_depth < 8)
58  {
59  png_ptr->transformations |= PNG_PACK;
60 # ifdef PNG_WRITE_SUPPORTED
61  png_ptr->usr_bit_depth = 8;
62 # endif
63  }
64 }
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte bit_depth
Definition: pngstruct.h:253
png_byte usr_bit_depth
Definition: pngstruct.h:254
png_uint_32 transformations
Definition: pngstruct.h:181
#define PNG_PACK
Definition: pngpriv.h:562
void png_set_packswap ( png_structrp  png_ptr)
71 {
72  png_debug(1, "in png_set_packswap");
73 
74  if (png_ptr == NULL)
75  return;
76 
77  if (png_ptr->bit_depth < 8)
78  png_ptr->transformations |= PNG_PACKSWAP;
79 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_PACKSWAP
Definition: pngpriv.h:576
png_byte bit_depth
Definition: pngstruct.h:253
png_uint_32 transformations
Definition: pngstruct.h:181
void png_set_shift ( png_structrp  png_ptr,
png_const_color_8p  true_bits 
)
85 {
86  png_debug(1, "in png_set_shift");
87 
88  if (png_ptr == NULL)
89  return;
90 
91  png_ptr->transformations |= PNG_SHIFT;
92  png_ptr->shift = *true_bits;
93 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_SHIFT
Definition: pngpriv.h:563
png_uint_32 transformations
Definition: pngstruct.h:181
int png_set_interlace_handling ( png_structrp  png_ptr)
100 {
101  png_debug(1, "in png_set_interlace handling");
102 
103  if (png_ptr != 0 && png_ptr->interlaced != 0)
104  {
105  png_ptr->transformations |= PNG_INTERLACE;
106  return (7);
107  }
108 
109  return (1);
110 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_INTERLACE
Definition: pngpriv.h:561
png_uint_32 transformations
Definition: pngstruct.h:181
png_byte interlaced
Definition: pngstruct.h:249
void png_set_filler ( png_structrp  png_ptr,
png_uint_32  filler,
int  filler_loc 
)
121 {
122  png_debug(1, "in png_set_filler");
123 
124  if (png_ptr == NULL)
125  return;
126 
127  /* In libpng 1.6 it is possible to determine whether this is a read or write
128  * operation and therefore to do more checking here for a valid call.
129  */
130  if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
131  {
132 # ifdef PNG_READ_FILLER_SUPPORTED
133  /* On read png_set_filler is always valid, regardless of the base PNG
134  * format, because other transformations can give a format where the
135  * filler code can execute (basically an 8 or 16-bit component RGB or G
136  * format.)
137  *
138  * NOTE: usr_channels is not used by the read code! (This has led to
139  * confusion in the past.) The filler is only used in the read code.
140  */
141  png_ptr->filler = (png_uint_16)filler;
142 # else
143  png_app_error(png_ptr, "png_set_filler not supported on read");
144  PNG_UNUSED(filler) /* not used in the write case */
145  return;
146 # endif
147  }
148 
149  else /* write */
150  {
151 # ifdef PNG_WRITE_FILLER_SUPPORTED
152  /* On write the usr_channels parameter must be set correctly at the
153  * start to record the number of channels in the app-supplied data.
154  */
155  switch (png_ptr->color_type)
156  {
157  case PNG_COLOR_TYPE_RGB:
158  png_ptr->usr_channels = 4;
159  break;
160 
161  case PNG_COLOR_TYPE_GRAY:
162  if (png_ptr->bit_depth >= 8)
163  {
164  png_ptr->usr_channels = 2;
165  break;
166  }
167 
168  else
169  {
170  /* There simply isn't any code in libpng to strip out bits
171  * from bytes when the components are less than a byte in
172  * size!
173  */
174  png_app_error(png_ptr,
175  "png_set_filler is invalid for low bit depth gray output");
176  return;
177  }
178 
179  default:
180  png_app_error(png_ptr,
181  "png_set_filler: inappropriate color type");
182  return;
183  }
184 # else
185  png_app_error(png_ptr, "png_set_filler not supported on write");
186  return;
187 # endif
188  }
189 
190  /* Here on success - libpng supports the operation, set the transformation
191  * and the flag to say where the filler channel is.
192  */
193  png_ptr->transformations |= PNG_FILLER;
194 
195  if (filler_loc == PNG_FILLER_AFTER)
196  png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
197 
198  else
199  png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
200 }
#define PNG_UNUSED(param)
Definition: pngpriv.h:367
#define PNG_COLOR_TYPE_RGB
Definition: png.h:811
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_IS_READ_STRUCT
Definition: pngpriv.h:557
png_byte color_type
Definition: pngstruct.h:252
#define PNG_FILLER
Definition: pngpriv.h:575
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:809
png_byte bit_depth
Definition: pngstruct.h:253
png_uint_32 mode
Definition: pngstruct.h:179
#define PNG_FILLER_AFTER
Definition: png.h:1387
#define PNG_FLAG_FILLER_AFTER
Definition: pngpriv.h:608
png_uint_32 transformations
Definition: pngstruct.h:181
void png_set_add_alpha ( png_structrp  png_ptr,
png_uint_32  filler,
int  filler_loc 
)
205 {
206  png_debug(1, "in png_set_add_alpha");
207 
208  if (png_ptr == NULL)
209  return;
210 
211  png_set_filler(png_ptr, filler, filler_loc);
212  /* The above may fail to do anything. */
213  if ((png_ptr->transformations & PNG_FILLER) != 0)
214  png_ptr->transformations |= PNG_ADD_ALPHA;
215 }
void png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
Definition: pngtrans.c:120
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_FILLER
Definition: pngpriv.h:575
#define PNG_ADD_ALPHA
Definition: pngpriv.h:585
png_uint_32 transformations
Definition: pngstruct.h:181
void png_set_swap_alpha ( png_structrp  png_ptr)
223 {
224  png_debug(1, "in png_set_swap_alpha");
225 
226  if (png_ptr == NULL)
227  return;
228 
229  png_ptr->transformations |= PNG_SWAP_ALPHA;
230 }
#define PNG_SWAP_ALPHA
Definition: pngpriv.h:577
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 transformations
Definition: pngstruct.h:181
void png_set_invert_alpha ( png_structrp  png_ptr)
237 {
238  png_debug(1, "in png_set_invert_alpha");
239 
240  if (png_ptr == NULL)
241  return;
242 
243  png_ptr->transformations |= PNG_INVERT_ALPHA;
244 }
#define PNG_INVERT_ALPHA
Definition: pngpriv.h:579
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 transformations
Definition: pngstruct.h:181
void png_set_invert_mono ( png_structrp  png_ptr)
250 {
251  png_debug(1, "in png_set_invert_mono");
252 
253  if (png_ptr == NULL)
254  return;
255 
256  png_ptr->transformations |= PNG_INVERT_MONO;
257 }
#define PNG_INVERT_MONO
Definition: pngpriv.h:565
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 transformations
Definition: pngstruct.h:181
void png_do_invert ( png_row_infop  row_info,
png_bytep  row 
)
262 {
263  png_debug(1, "in png_do_invert");
264 
265  /* This test removed from libpng version 1.0.13 and 1.2.0:
266  * if (row_info->bit_depth == 1 &&
267  */
268  if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
269  {
270  png_bytep rp = row;
271  png_size_t i;
272  png_size_t istop = row_info->rowbytes;
273 
274  for (i = 0; i < istop; i++)
275  {
276  *rp = (png_byte)(~(*rp));
277  rp++;
278  }
279  }
280 
281  else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
282  row_info->bit_depth == 8)
283  {
284  png_bytep rp = row;
285  png_size_t i;
286  png_size_t istop = row_info->rowbytes;
287 
288  for (i = 0; i < istop; i += 2)
289  {
290  *rp = (png_byte)(~(*rp));
291  rp += 2;
292  }
293  }
294 
295 #ifdef PNG_16BIT_SUPPORTED
296  else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
297  row_info->bit_depth == 16)
298  {
299  png_bytep rp = row;
300  png_size_t i;
301  png_size_t istop = row_info->rowbytes;
302 
303  for (i = 0; i < istop; i += 4)
304  {
305  *rp = (png_byte)(~(*rp));
306  *(rp + 1) = (png_byte)(~(*(rp + 1)));
307  rp += 4;
308  }
309  }
310 #endif
311 }
int i
Definition: rw_test.cpp:37
#define PNG_COLOR_TYPE_GRAY_ALPHA
Definition: png.h:813
png_byte * png_bytep
Definition: pngconf.h:600
#define png_debug(l, m)
Definition: pngdebug.h:146
png_byte color_type
Definition: png.h:898
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:809
png_size_t rowbytes
Definition: png.h:897
size_t png_size_t
Definition: pngconf.h:543
png_byte bit_depth
Definition: png.h:899
void png_do_swap ( png_row_infop  row_info,
png_bytep  row 
)
319 {
320  png_debug(1, "in png_do_swap");
321 
322  if (row_info->bit_depth == 16)
323  {
324  png_bytep rp = row;
325  png_uint_32 i;
326  png_uint_32 istop= row_info->width * row_info->channels;
327 
328  for (i = 0; i < istop; i++, rp += 2)
329  {
330 #ifdef PNG_BUILTIN_BSWAP16_SUPPORTED
331  /* Feature added to libpng-1.6.11 for testing purposes, not
332  * enabled by default.
333  */
334  *(png_uint_16*)rp = __builtin_bswap16(*(png_uint_16*)rp);
335 #else
336  png_byte t = *rp;
337  *rp = *(rp + 1);
338  *(rp + 1) = t;
339 #endif
340  }
341  }
342 }
int i
Definition: rw_test.cpp:37
png_byte * png_bytep
Definition: pngconf.h:600
#define png_debug(l, m)
Definition: pngdebug.h:146
png_uint_32 width
Definition: png.h:896
png_byte channels
Definition: png.h:900
png_byte bit_depth
Definition: png.h:899
void png_do_packswap ( png_row_infop  row_info,
png_bytep  row 
)
455 {
456  png_debug(1, "in png_do_packswap");
457 
458  if (row_info->bit_depth < 8)
459  {
460  png_bytep rp;
461  png_const_bytep end, table;
462 
463  end = row + row_info->rowbytes;
464 
465  if (row_info->bit_depth == 1)
466  table = onebppswaptable;
467 
468  else if (row_info->bit_depth == 2)
469  table = twobppswaptable;
470 
471  else if (row_info->bit_depth == 4)
472  table = fourbppswaptable;
473 
474  else
475  return;
476 
477  for (rp = row; rp < end; rp++)
478  *rp = table[*rp];
479  }
480 }
png_byte * png_bytep
Definition: pngconf.h:600
#define png_debug(l, m)
Definition: pngdebug.h:146
const png_byte * png_const_bytep
Definition: pngconf.h:601
static const png_byte twobppswaptable[256]
Definition: pngtrans.c:382
png_size_t rowbytes
Definition: png.h:897
static const png_byte fourbppswaptable[256]
Definition: pngtrans.c:417
static const png_byte onebppswaptable[256]
Definition: pngtrans.c:347
png_byte bit_depth
Definition: png.h:899
void png_do_strip_channel ( png_row_infop  row_info,
png_bytep  row,
int  at_start 
)
495 {
496  png_bytep sp = row; /* source pointer */
497  png_bytep dp = row; /* destination pointer */
498  png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
499 
500  /* At the start sp will point to the first byte to copy and dp to where
501  * it is copied to. ep always points just beyond the end of the row, so
502  * the loop simply copies (channels-1) channels until sp reaches ep.
503  *
504  * at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc.
505  * nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc.
506  */
507 
508  /* GA, GX, XG cases */
509  if (row_info->channels == 2)
510  {
511  if (row_info->bit_depth == 8)
512  {
513  if (at_start != 0) /* Skip initial filler */
514  ++sp;
515  else /* Skip initial channel and, for sp, the filler */
516  sp += 2, ++dp;
517 
518  /* For a 1 pixel wide image there is nothing to do */
519  while (sp < ep)
520  *dp++ = *sp, sp += 2;
521 
522  row_info->pixel_depth = 8;
523  }
524 
525  else if (row_info->bit_depth == 16)
526  {
527  if (at_start != 0) /* Skip initial filler */
528  sp += 2;
529  else /* Skip initial channel and, for sp, the filler */
530  sp += 4, dp += 2;
531 
532  while (sp < ep)
533  *dp++ = *sp++, *dp++ = *sp, sp += 3;
534 
535  row_info->pixel_depth = 16;
536  }
537 
538  else
539  return; /* bad bit depth */
540 
541  row_info->channels = 1;
542 
543  /* Finally fix the color type if it records an alpha channel */
544  if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
545  row_info->color_type = PNG_COLOR_TYPE_GRAY;
546  }
547 
548  /* RGBA, RGBX, XRGB cases */
549  else if (row_info->channels == 4)
550  {
551  if (row_info->bit_depth == 8)
552  {
553  if (at_start != 0) /* Skip initial filler */
554  ++sp;
555  else /* Skip initial channels and, for sp, the filler */
556  sp += 4, dp += 3;
557 
558  /* Note that the loop adds 3 to dp and 4 to sp each time. */
559  while (sp < ep)
560  *dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
561 
562  row_info->pixel_depth = 24;
563  }
564 
565  else if (row_info->bit_depth == 16)
566  {
567  if (at_start != 0) /* Skip initial filler */
568  sp += 2;
569  else /* Skip initial channels and, for sp, the filler */
570  sp += 8, dp += 6;
571 
572  while (sp < ep)
573  {
574  /* Copy 6 bytes, skip 2 */
575  *dp++ = *sp++, *dp++ = *sp++;
576  *dp++ = *sp++, *dp++ = *sp++;
577  *dp++ = *sp++, *dp++ = *sp, sp += 3;
578  }
579 
580  row_info->pixel_depth = 48;
581  }
582 
583  else
584  return; /* bad bit depth */
585 
586  row_info->channels = 3;
587 
588  /* Finally fix the color type if it records an alpha channel */
589  if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
590  row_info->color_type = PNG_COLOR_TYPE_RGB;
591  }
592 
593  else
594  return; /* The filler channel has gone already */
595 
596  /* Fix the rowbytes value. */
597  row_info->rowbytes = dp-row;
598 }
#define PNG_COLOR_TYPE_RGB
Definition: png.h:811
#define PNG_COLOR_TYPE_GRAY_ALPHA
Definition: png.h:813
png_byte * png_bytep
Definition: pngconf.h:600
#define PNG_COLOR_TYPE_RGB_ALPHA
Definition: png.h:812
png_byte color_type
Definition: png.h:898
png_byte channels
Definition: png.h:900
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:809
png_byte pixel_depth
Definition: png.h:901
png_size_t rowbytes
Definition: png.h:897
png_byte bit_depth
Definition: png.h:899
void png_do_bgr ( png_row_infop  row_info,
png_bytep  row 
)
605 {
606  png_debug(1, "in png_do_bgr");
607 
608  if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
609  {
610  png_uint_32 row_width = row_info->width;
611  if (row_info->bit_depth == 8)
612  {
613  if (row_info->color_type == PNG_COLOR_TYPE_RGB)
614  {
615  png_bytep rp;
616  png_uint_32 i;
617 
618  for (i = 0, rp = row; i < row_width; i++, rp += 3)
619  {
620  png_byte save = *rp;
621  *rp = *(rp + 2);
622  *(rp + 2) = save;
623  }
624  }
625 
626  else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
627  {
628  png_bytep rp;
629  png_uint_32 i;
630 
631  for (i = 0, rp = row; i < row_width; i++, rp += 4)
632  {
633  png_byte save = *rp;
634  *rp = *(rp + 2);
635  *(rp + 2) = save;
636  }
637  }
638  }
639 
640 #ifdef PNG_16BIT_SUPPORTED
641  else if (row_info->bit_depth == 16)
642  {
643  if (row_info->color_type == PNG_COLOR_TYPE_RGB)
644  {
645  png_bytep rp;
646  png_uint_32 i;
647 
648  for (i = 0, rp = row; i < row_width; i++, rp += 6)
649  {
650  png_byte save = *rp;
651  *rp = *(rp + 4);
652  *(rp + 4) = save;
653  save = *(rp + 1);
654  *(rp + 1) = *(rp + 5);
655  *(rp + 5) = save;
656  }
657  }
658 
659  else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
660  {
661  png_bytep rp;
662  png_uint_32 i;
663 
664  for (i = 0, rp = row; i < row_width; i++, rp += 8)
665  {
666  png_byte save = *rp;
667  *rp = *(rp + 4);
668  *(rp + 4) = save;
669  save = *(rp + 1);
670  *(rp + 1) = *(rp + 5);
671  *(rp + 5) = save;
672  }
673  }
674  }
675 #endif
676  }
677 }
int i
Definition: rw_test.cpp:37
#define PNG_COLOR_TYPE_RGB
Definition: png.h:811
png_byte * png_bytep
Definition: pngconf.h:600
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_COLOR_TYPE_RGB_ALPHA
Definition: png.h:812
png_uint_32 width
Definition: png.h:896
png_byte color_type
Definition: png.h:898
#define PNG_COLOR_MASK_COLOR
Definition: png.h:805
png_byte bit_depth
Definition: png.h:899
void png_do_check_palette_indexes ( png_structrp  png_ptr,
png_row_infop  row_info 
)
685 {
686  if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
687  png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
688  {
689  /* Calculations moved outside switch in an attempt to stop different
690  * compiler warnings. 'padding' is in *bits* within the last byte, it is
691  * an 'int' because pixel_depth becomes an 'int' in the expression below,
692  * and this calculation is used because it avoids warnings that other
693  * forms produced on either GCC or MSVC.
694  */
695  int padding = (-row_info->pixel_depth * row_info->width) & 7;
696  png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
697 
698  switch (row_info->bit_depth)
699  {
700  case 1:
701  {
702  /* in this case, all bytes must be 0 so we don't need
703  * to unpack the pixels except for the rightmost one.
704  */
705  for (; rp > png_ptr->row_buf; rp--)
706  {
707  if (*rp >> padding != 0)
708  png_ptr->num_palette_max = 1;
709  padding = 0;
710  }
711 
712  break;
713  }
714 
715  case 2:
716  {
717  for (; rp > png_ptr->row_buf; rp--)
718  {
719  int i = ((*rp >> padding) & 0x03);
720 
721  if (i > png_ptr->num_palette_max)
722  png_ptr->num_palette_max = i;
723 
724  i = (((*rp >> padding) >> 2) & 0x03);
725 
726  if (i > png_ptr->num_palette_max)
727  png_ptr->num_palette_max = i;
728 
729  i = (((*rp >> padding) >> 4) & 0x03);
730 
731  if (i > png_ptr->num_palette_max)
732  png_ptr->num_palette_max = i;
733 
734  i = (((*rp >> padding) >> 6) & 0x03);
735 
736  if (i > png_ptr->num_palette_max)
737  png_ptr->num_palette_max = i;
738 
739  padding = 0;
740  }
741 
742  break;
743  }
744 
745  case 4:
746  {
747  for (; rp > png_ptr->row_buf; rp--)
748  {
749  int i = ((*rp >> padding) & 0x0f);
750 
751  if (i > png_ptr->num_palette_max)
752  png_ptr->num_palette_max = i;
753 
754  i = (((*rp >> padding) >> 4) & 0x0f);
755 
756  if (i > png_ptr->num_palette_max)
757  png_ptr->num_palette_max = i;
758 
759  padding = 0;
760  }
761 
762  break;
763  }
764 
765  case 8:
766  {
767  for (; rp > png_ptr->row_buf; rp--)
768  {
769  if (*rp > png_ptr->num_palette_max)
770  png_ptr->num_palette_max = (int) *rp;
771  }
772 
773  break;
774  }
775 
776  default:
777  break;
778  }
779  }
780 }
int i
Definition: rw_test.cpp:37
png_byte * png_bytep
Definition: pngconf.h:600
png_uint_32 width
Definition: png.h:896
png_bytep row_buf
Definition: pngstruct.h:225
png_uint_16 num_palette
Definition: pngstruct.h:239
png_byte pixel_depth
Definition: png.h:901
png_size_t rowbytes
Definition: png.h:897
png_byte bit_depth
Definition: png.h:899
void png_set_user_transform_info ( png_structrp  png_ptr,
png_voidp  user_transform_ptr,
int  user_transform_depth,
int  user_transform_channels 
)
789 {
790  png_debug(1, "in png_set_user_transform_info");
791 
792  if (png_ptr == NULL)
793  return;
794 
795 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
796  if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
797  (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
798  {
799  png_app_error(png_ptr,
800  "info change after png_start_read_image or png_read_update_info");
801  return;
802  }
803 #endif
804 
805  png_ptr->user_transform_ptr = user_transform_ptr;
806  png_ptr->user_transform_depth = (png_byte)user_transform_depth;
807  png_ptr->user_transform_channels = (png_byte)user_transform_channels;
808 }
#define png_debug(l, m)
Definition: pngdebug.h:146
#define PNG_IS_READ_STRUCT
Definition: pngpriv.h:557
#define PNG_FLAG_ROW_INIT
Definition: pngpriv.h:607
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
png_uint_32 flags
Definition: pngstruct.h:180
png_uint_32 mode
Definition: pngstruct.h:179
png_voidp png_get_user_transform_ptr ( png_const_structrp  png_ptr)
819 {
820  if (png_ptr == NULL)
821  return (NULL);
822 
823  return png_ptr->user_transform_ptr;
824 }
png_uint_32 png_get_current_row_number ( png_const_structrp  png_ptr)
830 {
831  /* See the comments in png.h - this is the sub-image row when reading an
832  * interlaced image.
833  */
834  if (png_ptr != NULL)
835  return png_ptr->row_number;
836 
837  return PNG_UINT_32_MAX; /* help the app not to fail silently */
838 }
png_uint_32 row_number
Definition: pngstruct.h:220
#define PNG_UINT_32_MAX
Definition: png.h:791
png_byte png_get_current_pass_number ( png_const_structrp  png_ptr)
842 {
843  if (png_ptr != NULL)
844  return png_ptr->pass;
845  return 8; /* invalid */
846 }
png_byte pass
Definition: pngstruct.h:250

Variable Documentation

const png_byte onebppswaptable[256]
static
const png_byte twobppswaptable[256]
static
const png_byte fourbppswaptable[256]
static