20 #define PNG_NO_PEDANTIC_WARNINGS 22 #ifdef PNG_READ_SUPPORTED 40 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
41 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE;
45 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
46 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE |
47 PNG_FLAG_CRC_CRITICAL_IGNORE;
52 "Can't discard critical data on CRC error.");
57 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
68 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
69 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE;
73 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
74 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE |
75 PNG_FLAG_CRC_ANCILLARY_NOWARN;
79 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
80 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN;
87 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
92 #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ 93 defined(PNG_FLOATING_POINT_SUPPORTED) 106 png_warning(png_ptr,
"Application must supply a known background gamma");
110 png_ptr->transformations |= PNG_BACKGROUND;
111 png_memcpy(&(png_ptr->background), background_color,
113 png_ptr->background_gamma = (float)background_gamma;
114 png_ptr->background_gamma_type = (
png_byte)(background_gamma_code);
115 png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
119 #ifdef PNG_READ_16_TO_8_SUPPORTED 128 png_ptr->transformations |= PNG_16_TO_8;
132 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED 140 png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
144 #ifdef PNG_READ_DITHER_SUPPORTED 154 typedef struct png_dsort_struct
156 struct png_dsort_struct FAR * next;
172 png_ptr->transformations |= PNG_DITHER;
184 if (num_palette > maximum_colors)
186 if (histogram !=
NULL)
215 for (j = 0; j <
i; j++)
217 if (histogram[png_ptr->dither_sort[j]]
218 < histogram[png_ptr->dither_sort[j + 1]])
222 t = png_ptr->dither_sort[j];
223 png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1];
224 png_ptr->dither_sort[j + 1] =
t;
247 palette[
i] = palette[j];
269 tmp_color = palette[j];
270 palette[j] = palette[
i];
271 palette[
i] = tmp_color;
273 png_ptr->dither_index[j] = (
png_byte)i;
283 int min_d, k, min_k, d_index;
286 d_index = png_ptr->dither_index[
i];
287 min_d = PNG_COLOR_DIST(palette[d_index], palette[0]);
292 d = PNG_COLOR_DIST(palette[d_index], palette[k]);
301 png_ptr->dither_index[
i] = (
png_byte)min_k;
305 png_free(png_ptr, png_ptr->dither_sort);
306 png_ptr->dither_sort =
NULL;
335 png_ptr->index_to_palette[
i] = (
png_byte)i;
336 png_ptr->palette_to_index[
i] = (
png_byte)i;
354 while (num_new_palette > maximum_colors)
356 for (i = 0; i < num_new_palette - 1; i++)
360 for (j = i + 1; j < num_new_palette; j++)
364 d = PNG_COLOR_DIST(palette[i], palette[j]);
384 for (i = 0; i <= max_d; i++)
390 for (p = hash[i];
p; p = p->next)
392 if ((
int)png_ptr->index_to_palette[p->left]
394 (
int)png_ptr->index_to_palette[p->right]
399 if (num_new_palette & 0x01)
411 palette[png_ptr->index_to_palette[j]]
412 = palette[num_new_palette];
419 if (png_ptr->dither_index[k] ==
420 png_ptr->index_to_palette[j])
421 png_ptr->dither_index[k] =
422 png_ptr->index_to_palette[next_j];
423 if ((
int)png_ptr->dither_index[k] ==
425 png_ptr->dither_index[k] =
426 png_ptr->index_to_palette[j];
430 png_ptr->index_to_palette[png_ptr->palette_to_index
431 [num_new_palette]] = png_ptr->index_to_palette[j];
432 png_ptr->palette_to_index[png_ptr->index_to_palette[j]]
433 = png_ptr->palette_to_index[num_new_palette];
435 png_ptr->index_to_palette[j] =
437 png_ptr->palette_to_index[num_new_palette] =
440 if (num_new_palette <= maximum_colors)
443 if (num_new_palette <= maximum_colors)
448 for (i = 0; i < 769; i++)
465 png_free(png_ptr, png_ptr->palette_to_index);
466 png_free(png_ptr, png_ptr->index_to_palette);
467 png_ptr->palette_to_index =
NULL;
468 png_ptr->index_to_palette =
NULL;
472 if (png_ptr->palette ==
NULL)
482 int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS +
483 PNG_DITHER_BLUE_BITS;
484 int num_red = (1 << PNG_DITHER_RED_BITS);
485 int num_green = (1 << PNG_DITHER_GREEN_BITS);
486 int num_blue = (1 << PNG_DITHER_BLUE_BITS);
499 int r = (palette[
i].red >> (8 - PNG_DITHER_RED_BITS));
500 int g = (palette[
i].green >> (8 - PNG_DITHER_GREEN_BITS));
501 int b = (palette[
i].blue >> (8 - PNG_DITHER_BLUE_BITS));
503 for (ir = 0; ir < num_red; ir++)
506 int dr = ((ir >
r) ? ir - r : r - ir);
507 int index_r = (ir << (PNG_DITHER_BLUE_BITS +
508 PNG_DITHER_GREEN_BITS));
510 for (ig = 0; ig < num_green; ig++)
513 int dg = ((ig >
g) ? ig - g : g - ig);
515 int dm = ((dr > dg) ? dr : dg);
516 int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS);
518 for (ib = 0; ib < num_blue; ib++)
520 int d_index = index_g | ib;
522 int db = ((ib >
b) ? ib - b : b - ib);
523 int dmax = ((dm > db) ? dm : db);
524 int d = dmax + dt + db;
526 if (d < (
int)distance[d_index])
529 png_ptr->palette_lookup[d_index] = (
png_byte)i;
541 #if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) 559 if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) ||
562 png_ptr->transformations |= PNG_GAMMA;
563 png_ptr->gamma = (float)file_gamma;
564 png_ptr->screen_gamma = (float)scrn_gamma;
568 #ifdef PNG_READ_EXPAND_SUPPORTED 581 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
582 png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
607 png_debug(1,
"in png_set_palette_to_rgb");
612 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
613 png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
621 png_debug(1,
"in png_set_expand_gray_1_2_4_to_8");
626 png_ptr->transformations |= PNG_EXPAND;
627 png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
631 #if defined(PNG_1_0_X) || defined(PNG_1_2_X) 637 png_debug(1,
"in png_set_gray_1_2_4_to_8");
642 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
651 png_debug(1,
"in png_set_tRNS_to_alpha");
653 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
654 png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
658 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 664 png_ptr->transformations |= PNG_GRAY_TO_RGB;
665 png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
669 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 670 #ifdef PNG_FLOATING_POINT_SUPPORTED 679 int red_fixed, green_fixed;
682 if (red > 21474.83647 || red < -21474.83648 ||
683 green > 21474.83647 || green < -21474.83648)
685 png_warning(png_ptr,
"ignoring out of range rgb_to_gray coefficients");
691 red_fixed = (
int)((
float)red*100000.0 + 0.5);
692 green_fixed = (
int)((
float)green*100000.0 + 0.5);
709 case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY;
712 case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN;
715 case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
718 #ifdef PNG_READ_EXPAND_SUPPORTED 719 png_ptr->transformations |= PNG_EXPAND;
723 "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED.");
724 png_ptr->transformations &= ~PNG_RGB_TO_GRAY;
729 if (red < 0 || green < 0)
734 else if (red + green < 100000L)
741 png_warning(png_ptr,
"ignoring out of range rgb_to_gray coefficients");
745 png_ptr->rgb_to_gray_red_coeff = red_int;
746 png_ptr->rgb_to_gray_green_coeff = green_int;
747 png_ptr->rgb_to_gray_blue_coeff =
753 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ 754 defined(PNG_LEGACY_SUPPORTED) || \ 755 defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) 760 png_debug(1,
"in png_set_read_user_transform_fn");
765 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 766 png_ptr->transformations |= PNG_USER_TRANSFORM;
769 #ifdef PNG_LEGACY_SUPPORTED 770 if (read_user_transform_fn)
772 "This version of libpng does not support user transforms");
783 png_debug(1,
"in png_init_read_transformations");
785 #ifdef PNG_USELESS_TESTS_SUPPORTED 789 #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ 790 defined(PNG_READ_SHIFT_SUPPORTED) || \ 791 defined(PNG_READ_GAMMA_SUPPORTED) 795 #if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) 797 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 808 if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
811 png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
812 }
else if ((png_ptr->transformations & PNG_BACKGROUND) &&
813 !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
814 (png_ptr->transformations & PNG_GRAY_TO_RGB) &&
815 png_ptr->background.red == png_ptr->background.green &&
816 png_ptr->background.red == png_ptr->background.blue)
818 png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
819 png_ptr->background.gray = png_ptr->background.red;
823 if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
824 (png_ptr->transformations & PNG_EXPAND))
826 if (!(color_type & PNG_COLOR_MASK_COLOR))
829 switch (png_ptr->bit_depth)
833 png_ptr->background.red = png_ptr->background.green
834 = png_ptr->background.blue = png_ptr->background.gray;
835 if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
838 png_ptr->trans_values.red = png_ptr->trans_values.green
839 = png_ptr->trans_values.blue = png_ptr->trans_values.gray;
845 png_ptr->background.red = png_ptr->background.green
846 = png_ptr->background.blue = png_ptr->background.gray;
847 if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
850 png_ptr->trans_values.red = png_ptr->trans_values.green
851 = png_ptr->trans_values.blue = png_ptr->trans_values.gray;
857 png_ptr->background.red = png_ptr->background.green
858 = png_ptr->background.blue = png_ptr->background.gray;
859 if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
862 png_ptr->trans_values.red = png_ptr->trans_values.green
863 = png_ptr->trans_values.blue = png_ptr->trans_values.gray;
870 png_ptr->background.red = png_ptr->background.green
871 = png_ptr->background.blue = png_ptr->background.gray;
877 png_ptr->background.red =
878 png_ptr->palette[png_ptr->background.index].red;
879 png_ptr->background.green =
880 png_ptr->palette[png_ptr->background.index].green;
881 png_ptr->background.blue =
882 png_ptr->palette[png_ptr->background.index].blue;
884 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED 885 if (png_ptr->transformations & PNG_INVERT_ALPHA)
887 #ifdef PNG_READ_EXPAND_SUPPORTED 888 if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
895 istop=(
int)png_ptr->num_trans;
896 for (i=0; i<istop; i++)
897 png_ptr->trans[i] = (
png_byte)(255 - png_ptr->trans[
i]);
906 #if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED) 907 png_ptr->background_1 = png_ptr->background;
909 #if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) 912 && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0)
913 < PNG_GAMMA_THRESHOLD))
917 for (i=0; i<png_ptr->num_trans; i++)
919 if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff)
926 png_ptr->transformations &= ~PNG_GAMMA;
929 if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) &&
930 png_ptr->gamma != 0.0)
934 #ifdef PNG_READ_BACKGROUND_SUPPORTED 935 if (png_ptr->transformations & PNG_BACKGROUND)
946 back.
red = png_ptr->gamma_table[png_ptr->background.red];
947 back.
green = png_ptr->gamma_table[png_ptr->background.green];
948 back.
blue = png_ptr->gamma_table[png_ptr->background.blue];
950 back_1.
red = png_ptr->gamma_to_1[png_ptr->background.red];
951 back_1.
green = png_ptr->gamma_to_1[png_ptr->background.green];
952 back_1.
blue = png_ptr->gamma_to_1[png_ptr->background.blue];
958 switch (png_ptr->background_gamma_type)
961 g = (png_ptr->screen_gamma);
966 g = 1.0 / (png_ptr->gamma);
967 gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
971 g = 1.0 / (png_ptr->background_gamma);
972 gs = 1.0 / (png_ptr->background_gamma *
973 png_ptr->screen_gamma);
980 if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD)
989 (
double)png_ptr->background.red/255, gs) * 255.0 + .5);
991 (
double)png_ptr->background.green/255, gs) * 255.0
994 (
double)png_ptr->background.blue/255, gs) * 255.0 + .5);
998 (
double)png_ptr->background.red/255,
g) * 255.0 + .5);
1000 (
double)png_ptr->background.green/255,
g) * 255.0 + .5);
1002 (
double)png_ptr->background.blue/255,
g) * 255.0 + .5);
1006 if (i < (
int)png_ptr->num_trans && png_ptr->trans[
i] != 0xff)
1008 if (png_ptr->trans[i] == 0)
1016 v = png_ptr->gamma_to_1[palette[
i].red];
1018 palette[
i].red = png_ptr->gamma_from_1[
w];
1020 v = png_ptr->gamma_to_1[palette[
i].green];
1022 palette[
i].green = png_ptr->gamma_from_1[
w];
1024 v = png_ptr->gamma_to_1[palette[
i].blue];
1026 palette[
i].blue = png_ptr->gamma_from_1[
w];
1031 palette[
i].red = png_ptr->gamma_table[palette[
i].red];
1032 palette[
i].green = png_ptr->gamma_table[palette[
i].green];
1033 palette[
i].blue = png_ptr->gamma_table[palette[
i].blue];
1041 png_ptr->transformations &= ~PNG_BACKGROUND;
1042 png_ptr->transformations &= ~PNG_GAMMA;
1043 png_ptr->transformations |= PNG_STRIP_ALPHA;
1049 double m = (double)(((
png_uint_32)1 << png_ptr->bit_depth) - 1);
1053 switch (png_ptr->background_gamma_type)
1056 g = (png_ptr->screen_gamma);
1061 g = 1.0 / (png_ptr->gamma);
1062 gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
1066 g = 1.0 / (png_ptr->background_gamma);
1067 gs = 1.0 / (png_ptr->background_gamma *
1068 png_ptr->screen_gamma);
1073 (
double)png_ptr->background.gray /
m,
g) * m + .5);
1075 (
double)png_ptr->background.gray /
m, gs) * m + .5);
1077 if ((png_ptr->background.red != png_ptr->background.green) ||
1078 (png_ptr->background.red != png_ptr->background.blue) ||
1079 (png_ptr->background.red != png_ptr->background.gray))
1083 (
double)png_ptr->background.red /
m,
g) * m + .5);
1085 (
double)png_ptr->background.green /
m,
g) * m + .5);
1087 (
double)png_ptr->background.blue /
m,
g) * m + .5);
1089 (
double)png_ptr->background.red /
m, gs) * m + .5);
1091 (
double)png_ptr->background.green /
m, gs) * m + .5);
1093 (
double)png_ptr->background.blue /
m, gs) * m + .5);
1098 png_ptr->background_1.red = png_ptr->background_1.green
1099 = png_ptr->background_1.blue = png_ptr->background_1.gray;
1100 png_ptr->background.red = png_ptr->background.green
1101 = png_ptr->background.blue = png_ptr->background.gray;
1116 palette[
i].red = png_ptr->gamma_table[palette[
i].red];
1117 palette[
i].green = png_ptr->gamma_table[palette[
i].green];
1118 palette[
i].blue = png_ptr->gamma_table[palette[
i].blue];
1122 png_ptr->transformations &= ~PNG_GAMMA;
1125 #ifdef PNG_READ_BACKGROUND_SUPPORTED 1129 #ifdef PNG_READ_BACKGROUND_SUPPORTED 1131 if ((png_ptr->transformations & PNG_BACKGROUND) &&
1135 int istop = (
int)png_ptr->num_trans;
1139 back.red = (
png_byte)png_ptr->background.red;
1140 back.green = (
png_byte)png_ptr->background.green;
1141 back.blue = (
png_byte)png_ptr->background.blue;
1143 for (i = 0; i < istop; i++)
1145 if (png_ptr->trans[i] == 0)
1149 else if (png_ptr->trans[i] != 0xff)
1153 png_ptr->trans[i], back.red);
1155 png_ptr->trans[i], back.green);
1157 png_ptr->trans[i], back.blue);
1162 png_ptr->transformations &= ~PNG_BACKGROUND;
1163 png_ptr->transformations |= PNG_STRIP_ALPHA;
1167 #ifdef PNG_READ_SHIFT_SUPPORTED 1168 if ((png_ptr->transformations & PNG_SHIFT) &&
1169 !(png_ptr->transformations & PNG_EXPAND) &&
1174 int sr = 8 - png_ptr->sig_bit.red;
1175 int sg = 8 - png_ptr->sig_bit.green;
1176 int sb = 8 - png_ptr->sig_bit.blue;
1178 if (sr < 0 || sr > 8)
1180 if (sg < 0 || sg > 8)
1182 if (sb < 0 || sb > 8)
1184 for (i = 0; i < istop; i++)
1186 png_ptr->palette[
i].red >>= sr;
1187 png_ptr->palette[
i].green >>= sg;
1188 png_ptr->palette[
i].blue >>= sb;
1191 png_ptr->transformations &= ~PNG_SHIFT;
1195 #if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ 1196 && !defined(PNG_READ_BACKGROUND_SUPPORTED) 1209 png_debug(1,
"in png_read_transform_info");
1211 #ifdef PNG_READ_EXPAND_SUPPORTED 1212 if (png_ptr->transformations & PNG_EXPAND)
1216 if (png_ptr->num_trans)
1220 info_ptr->bit_depth = 8;
1221 info_ptr->num_trans = 0;
1225 if (png_ptr->num_trans)
1227 if (png_ptr->transformations & PNG_EXPAND_tRNS)
1230 if (info_ptr->bit_depth < 8)
1231 info_ptr->bit_depth = 8;
1232 info_ptr->num_trans = 0;
1237 #ifdef PNG_READ_BACKGROUND_SUPPORTED 1238 if (png_ptr->transformations & PNG_BACKGROUND)
1241 info_ptr->num_trans = 0;
1242 info_ptr->background = png_ptr->background;
1246 #ifdef PNG_READ_GAMMA_SUPPORTED 1247 if (png_ptr->transformations & PNG_GAMMA)
1249 #ifdef PNG_FLOATING_POINT_SUPPORTED 1250 info_ptr->gamma = png_ptr->gamma;
1252 #ifdef PNG_FIXED_POINT_SUPPORTED 1253 info_ptr->int_gamma = png_ptr->int_gamma;
1258 #ifdef PNG_READ_16_TO_8_SUPPORTED 1259 if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16))
1260 info_ptr->bit_depth = 8;
1263 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 1264 if (png_ptr->transformations & PNG_GRAY_TO_RGB)
1268 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 1269 if (png_ptr->transformations & PNG_RGB_TO_GRAY)
1273 #ifdef PNG_READ_DITHER_SUPPORTED 1274 if (png_ptr->transformations & PNG_DITHER)
1278 png_ptr->palette_lookup && info_ptr->bit_depth == 8)
1285 #ifdef PNG_READ_PACK_SUPPORTED 1286 if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))
1287 info_ptr->bit_depth = 8;
1291 info_ptr->channels = 1;
1293 info_ptr->channels = 3;
1295 info_ptr->channels = 1;
1297 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED 1298 if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)
1303 info_ptr->channels++;
1305 #ifdef PNG_READ_FILLER_SUPPORTED 1307 if ((png_ptr->transformations & PNG_FILLER) &&
1311 info_ptr->channels++;
1314 if (png_ptr->transformations & PNG_ADD_ALPHA)
1320 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ 1321 defined(PNG_READ_USER_TRANSFORM_SUPPORTED) 1322 if (png_ptr->transformations & PNG_USER_TRANSFORM)
1324 if (info_ptr->bit_depth < png_ptr->user_transform_depth)
1325 info_ptr->bit_depth = png_ptr->user_transform_depth;
1326 if (info_ptr->channels < png_ptr->user_transform_channels)
1327 info_ptr->channels = png_ptr->user_transform_channels;
1331 info_ptr->pixel_depth = (
png_byte)(info_ptr->channels *
1332 info_ptr->bit_depth);
1334 info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
1336 #ifndef PNG_READ_EXPAND_SUPPORTED 1349 png_debug(1,
"in png_do_read_transformations");
1351 if (png_ptr->row_buf ==
NULL)
1353 #if defined(PNG_STDIO_SUPPORTED) && !defined(_WIN32_WCE) 1357 "NULL row buffer for row %ld, pass %d", (
long)png_ptr->row_number,
1364 #ifdef PNG_WARN_UNINITIALIZED_ROW 1365 if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
1370 #if (PNG_WARN_UNINITIALIZED_ROW==1) 1371 png_error(png_ptr,
"Uninitialized row");
1377 #ifdef PNG_READ_EXPAND_SUPPORTED 1378 if (png_ptr->transformations & PNG_EXPAND)
1382 if (png_ptr->palette ==
NULL)
1383 png_error (png_ptr,
"Palette is NULL in indexed image");
1386 png_ptr->palette, png_ptr->trans, png_ptr->num_trans);
1390 if (png_ptr->num_trans &&
1391 (png_ptr->transformations & PNG_EXPAND_tRNS))
1393 &(png_ptr->trans_values));
1401 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED 1402 if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)
1404 PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA));
1407 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 1408 if (png_ptr->transformations & PNG_RGB_TO_GRAY)
1412 png_ptr->row_buf + 1);
1415 png_ptr->rgb_to_gray_status=1;
1416 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
1417 PNG_RGB_TO_GRAY_WARN)
1418 png_warning(png_ptr,
"png_do_rgb_to_gray found nongray pixel");
1419 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
1420 PNG_RGB_TO_GRAY_ERR)
1421 png_error(png_ptr,
"png_do_rgb_to_gray found nongray pixel");
1457 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 1461 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
1462 !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
1466 #ifdef PNG_READ_BACKGROUND_SUPPORTED 1467 if ((png_ptr->transformations & PNG_BACKGROUND) &&
1468 ((png_ptr->num_trans != 0 ) ||
1471 &(png_ptr->trans_values), &(png_ptr->background)
1473 , &(png_ptr->background_1),
1474 png_ptr->gamma_table, png_ptr->gamma_from_1,
1475 png_ptr->gamma_to_1, png_ptr->gamma_16_table,
1476 png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1,
1477 png_ptr->gamma_shift
1482 #ifdef PNG_READ_GAMMA_SUPPORTED 1483 if ((png_ptr->transformations & PNG_GAMMA) &&
1485 !((png_ptr->transformations & PNG_BACKGROUND) &&
1486 ((png_ptr->num_trans != 0) ||
1490 png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1,
1491 png_ptr->gamma_table, png_ptr->gamma_16_table,
1492 png_ptr->gamma_shift);
1495 #ifdef PNG_READ_16_TO_8_SUPPORTED 1496 if (png_ptr->transformations & PNG_16_TO_8)
1497 png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
1500 #ifdef PNG_READ_DITHER_SUPPORTED 1501 if (png_ptr->transformations & PNG_DITHER)
1504 png_ptr->palette_lookup, png_ptr->dither_index);
1506 png_error(png_ptr,
"png_do_dither returned rowbytes=0");
1510 #ifdef PNG_READ_INVERT_SUPPORTED 1511 if (png_ptr->transformations & PNG_INVERT_MONO)
1515 #ifdef PNG_READ_SHIFT_SUPPORTED 1516 if (png_ptr->transformations & PNG_SHIFT)
1521 #ifdef PNG_READ_PACK_SUPPORTED 1522 if (png_ptr->transformations & PNG_PACK)
1526 #ifdef PNG_READ_BGR_SUPPORTED 1527 if (png_ptr->transformations & PNG_BGR)
1528 png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
1531 #ifdef PNG_READ_PACKSWAP_SUPPORTED 1532 if (png_ptr->transformations & PNG_PACKSWAP)
1536 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 1538 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
1539 (png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
1543 #ifdef PNG_READ_FILLER_SUPPORTED 1544 if (png_ptr->transformations & PNG_FILLER)
1549 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED 1550 if (png_ptr->transformations & PNG_INVERT_ALPHA)
1554 #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED 1555 if (png_ptr->transformations & PNG_SWAP_ALPHA)
1559 #ifdef PNG_READ_SWAP_SUPPORTED 1560 if (png_ptr->transformations & PNG_SWAP_BYTES)
1561 png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
1564 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED 1565 if (png_ptr->transformations & PNG_USER_TRANSFORM)
1567 if (png_ptr->read_user_transform_fn !=
NULL)
1568 (*(png_ptr->read_user_transform_fn))
1570 &(png_ptr->row_info),
1577 png_ptr->row_buf + 1);
1578 #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED 1579 if (png_ptr->user_transform_depth)
1580 png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
1581 if (png_ptr->user_transform_channels)
1582 png_ptr->row_info.channels = png_ptr->user_transform_channels;
1584 png_ptr->row_info.pixel_depth = (
png_byte)(png_ptr->row_info.bit_depth *
1585 png_ptr->row_info.channels);
1586 png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
1587 png_ptr->row_info.width);
1593 #ifdef PNG_READ_PACK_SUPPORTED 1605 #ifdef PNG_USELESS_TESTS_SUPPORTED 1606 if (row !=
NULL && row_info !=
NULL && row_info->bit_depth < 8)
1608 if (row_info->bit_depth < 8)
1614 switch (row_info->bit_depth)
1621 for (i = 0; i < row_width; i++)
1623 *dp = (
png_byte)((*sp >> shift) & 0x01);
1643 for (i = 0; i < row_width; i++)
1645 *dp = (
png_byte)((*sp >> shift) & 0x03);
1664 for (i = 0; i < row_width; i++)
1666 *dp = (
png_byte)((*sp >> shift) & 0x0f);
1680 row_info->bit_depth = 8;
1681 row_info->pixel_depth = (
png_byte)(8 * row_info->channels);
1682 row_info->rowbytes = row_width * row_info->channels;
1687 #ifdef PNG_READ_SHIFT_SUPPORTED 1699 #ifdef PNG_USELESS_TESTS_SUPPORTED
1712 shift[channels++] = row_info->bit_depth - sig_bits->red;
1713 shift[channels++] = row_info->bit_depth - sig_bits->green;
1714 shift[channels++] = row_info->bit_depth - sig_bits->blue;
1718 shift[channels++] = row_info->bit_depth - sig_bits->gray;
1722 shift[channels++] = row_info->bit_depth - sig_bits->alpha;
1736 switch (row_info->bit_depth)
1744 for (bp = row, i = 0; i < istop; i++)
1760 for (i = 0; i < istop; i++)
1774 for (i = 0; i < istop; i++)
1787 for (i = 0; i < istop; i++)
1801 #ifdef PNG_READ_16_TO_8_SUPPORTED 1808 #ifdef PNG_USELESS_TESTS_SUPPORTED 1809 if (row !=
NULL && row_info !=
NULL && row_info->bit_depth == 16)
1811 if (row_info->bit_depth == 16)
1817 png_uint_32 istop = row_info->width * row_info->channels;
1819 for (i = 0; i<istop; i++, sp += 2, dp++)
1821 #ifdef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED 1847 *dp = *sp + ((((
int)(*(sp + 1)) - *sp) > 128) ? 1 : 0);
1853 row_info->bit_depth = 8;
1854 row_info->pixel_depth = (
png_byte)(8 * row_info->channels);
1855 row_info->rowbytes = row_info->width * row_info->channels;
1860 #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED 1864 png_debug(1,
"in png_do_read_swap_alpha");
1866 #ifdef PNG_USELESS_TESTS_SUPPORTED 1867 if (row !=
NULL && row_info !=
NULL)
1874 if (row_info->bit_depth == 8)
1876 png_bytep sp = row + row_info->rowbytes;
1881 for (i = 0; i < row_width; i++)
1893 png_bytep sp = row + row_info->rowbytes;
1898 for (i = 0; i < row_width; i++)
1916 if (row_info->bit_depth == 8)
1918 png_bytep sp = row + row_info->rowbytes;
1923 for (i = 0; i < row_width; i++)
1933 png_bytep sp = row + row_info->rowbytes;
1938 for (i = 0; i < row_width; i++)
1953 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED 1957 png_debug(1,
"in png_do_read_invert_alpha");
1959 #ifdef PNG_USELESS_TESTS_SUPPORTED 1960 if (row !=
NULL && row_info !=
NULL)
1967 if (row_info->bit_depth == 8)
1969 png_bytep sp = row + row_info->rowbytes;
1973 for (i = 0; i < row_width; i++)
1975 *(--dp) = (
png_byte)(255 - *(--sp));
1990 png_bytep sp = row + row_info->rowbytes;
1994 for (i = 0; i < row_width; i++)
1996 *(--dp) = (
png_byte)(255 - *(--sp));
1997 *(--dp) = (
png_byte)(255 - *(--sp));
2016 if (row_info->bit_depth == 8)
2018 png_bytep sp = row + row_info->rowbytes;
2022 for (i = 0; i < row_width; i++)
2024 *(--dp) = (
png_byte)(255 - *(--sp));
2031 png_bytep sp = row + row_info->rowbytes;
2035 for (i = 0; i < row_width; i++)
2037 *(--dp) = (
png_byte)(255 - *(--sp));
2038 *(--dp) = (
png_byte)(255 - *(--sp));
2052 #ifdef PNG_READ_FILLER_SUPPORTED 2067 #ifdef PNG_USELESS_TESTS_SUPPORTED
2072 if (row_info->bit_depth == 8)
2075 if (flags & PNG_FLAG_FILLER_AFTER)
2079 for (i = 1; i < row_width; i++)
2081 *(--dp) = lo_filler;
2084 *(--dp) = lo_filler;
2085 row_info->channels = 2;
2086 row_info->pixel_depth = 16;
2087 row_info->rowbytes = row_width * 2;
2094 for (i = 0; i < row_width; i++)
2097 *(--dp) = lo_filler;
2099 row_info->channels = 2;
2100 row_info->pixel_depth = 16;
2101 row_info->rowbytes = row_width * 2;
2104 else if (row_info->bit_depth == 16)
2107 if (flags & PNG_FLAG_FILLER_AFTER)
2111 for (i = 1; i < row_width; i++)
2113 *(--dp) = hi_filler;
2114 *(--dp) = lo_filler;
2118 *(--dp) = hi_filler;
2119 *(--dp) = lo_filler;
2120 row_info->channels = 2;
2121 row_info->pixel_depth = 32;
2122 row_info->rowbytes = row_width * 4;
2129 for (i = 0; i < row_width; i++)
2133 *(--dp) = hi_filler;
2134 *(--dp) = lo_filler;
2136 row_info->channels = 2;
2137 row_info->pixel_depth = 32;
2138 row_info->rowbytes = row_width * 4;
2144 if (row_info->bit_depth == 8)
2147 if (flags & PNG_FLAG_FILLER_AFTER)
2151 for (i = 1; i < row_width; i++)
2153 *(--dp) = lo_filler;
2158 *(--dp) = lo_filler;
2159 row_info->channels = 4;
2160 row_info->pixel_depth = 32;
2161 row_info->rowbytes = row_width * 4;
2168 for (i = 0; i < row_width; i++)
2173 *(--dp) = lo_filler;
2175 row_info->channels = 4;
2176 row_info->pixel_depth = 32;
2177 row_info->rowbytes = row_width * 4;
2180 else if (row_info->bit_depth == 16)
2183 if (flags & PNG_FLAG_FILLER_AFTER)
2187 for (i = 1; i < row_width; i++)
2189 *(--dp) = hi_filler;
2190 *(--dp) = lo_filler;
2198 *(--dp) = hi_filler;
2199 *(--dp) = lo_filler;
2200 row_info->channels = 4;
2201 row_info->pixel_depth = 64;
2202 row_info->rowbytes = row_width * 8;
2209 for (i = 0; i < row_width; i++)
2217 *(--dp) = hi_filler;
2218 *(--dp) = lo_filler;
2220 row_info->channels = 4;
2221 row_info->pixel_depth = 64;
2222 row_info->rowbytes = row_width * 8;
2229 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED 2239 if (row_info->bit_depth >= 8 &&
2240 #ifdef PNG_USELESS_TESTS_SUPPORTED
2247 if (row_info->bit_depth == 8)
2251 for (i = 0; i < row_width; i++)
2262 for (i = 0; i < row_width; i++)
2265 *(dp--) = *(sp - 1);
2267 *(dp--) = *(sp - 1);
2275 if (row_info->bit_depth == 8)
2279 for (i = 0; i < row_width; i++)
2291 for (i = 0; i < row_width; i++)
2296 *(dp--) = *(sp - 1);
2298 *(dp--) = *(sp - 1);
2306 row_info->pixel_depth = (
png_byte)(row_info->channels *
2307 row_info->bit_depth);
2308 row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
2313 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED 2347 #ifdef PNG_USELESS_TESTS_SUPPORTED
2353 png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
2358 if (row_info->bit_depth == 8)
2360 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 2361 if (png_ptr->gamma_from_1 !=
NULL && png_ptr->gamma_to_1 !=
NULL)
2366 for (i = 0; i < row_width; i++)
2371 if (red != green || red != blue)
2374 *(dp++) = png_ptr->gamma_from_1[
2375 (rc*red + gc*green + bc*blue)>>15];
2378 *(dp++) = *(sp - 1);
2386 for (i = 0; i < row_width; i++)
2391 if (red != green || red != blue)
2394 *(dp++) = (
png_byte)((rc*red + gc*green + bc*
blue)>>15);
2397 *(dp++) = *(sp - 1);
2404 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 2405 if (png_ptr->gamma_16_to_1 !=
NULL &&
2406 png_ptr->gamma_16_from_1 !=
NULL)
2410 for (i = 0; i < row_width; i++)
2415 hi=*(sp)++; lo=*(sp)++;
2417 hi=*(sp)++; lo=*(sp)++;
2419 hi=*(sp)++; lo=*(sp)++;
2422 if (red == green && red == blue)
2426 png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >>
2427 png_ptr->gamma_shift][red>>8];
2429 png_ptr->gamma_16_to_1[(green&0xff) >>
2430 png_ptr->gamma_shift][green>>8];
2431 png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
2432 png_ptr->gamma_shift][blue>>8];
2435 w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
2436 png_ptr->gamma_shift][gray16 >> 8];
2440 *(dp++) = (
png_byte)((w>>8) & 0xff);
2449 for (i = 0; i < row_width; i++)
2454 hi=*(sp)++; lo=*(sp)++;
2456 hi=*(sp)++; lo=*(sp)++;
2458 hi=*(sp)++; lo=*(sp)++;
2461 if (red != green || red != blue)
2463 gray16 = (
png_uint_16)((rc*red + gc*green + bc*blue)>>15);
2464 *(dp++) = (
png_byte)((gray16>>8) & 0xff);
2465 *(dp++) = (
png_byte)(gray16 & 0xff);
2472 if (row_info->bit_depth == 8)
2474 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 2475 if (png_ptr->gamma_from_1 !=
NULL && png_ptr->gamma_to_1 !=
NULL)
2479 for (i = 0; i < row_width; i++)
2484 if (red != green || red != blue)
2486 *(dp++) = png_ptr->gamma_from_1
2487 [(rc*red + gc*green + bc*blue)>>15];
2496 for (i = 0; i < row_width; i++)
2501 if (red != green || red != blue)
2503 *(dp++) = (
png_byte)((rc*red + gc*green + bc*
blue)>>15);
2510 #if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) 2511 if (png_ptr->gamma_16_to_1 !=
NULL &&
2512 png_ptr->gamma_16_from_1 !=
NULL)
2516 for (i = 0; i < row_width; i++)
2521 hi=*(sp)++; lo=*(sp)++;
2523 hi=*(sp)++; lo=*(sp)++;
2525 hi=*(sp)++; lo=*(sp)++;
2528 if (red == green && red == blue)
2532 png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >>
2533 png_ptr->gamma_shift][red>>8];
2535 png_ptr->gamma_16_to_1[(green&0xff) >>
2536 png_ptr->gamma_shift][green>>8];
2537 png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
2538 png_ptr->gamma_shift][blue>>8];
2540 + gc * green_1 + bc * blue_1)>>15);
2541 w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
2542 png_ptr->gamma_shift][gray16 >> 8];
2546 *(dp++) = (
png_byte)((w>>8) & 0xff);
2557 for (i = 0; i < row_width; i++)
2561 green = (
png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
2562 blue = (
png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
2563 if (red != green || red != blue)
2565 gray16 = (
png_uint_16)((rc*red + gc*green + bc*blue)>>15);
2566 *(dp++) = (
png_byte)((gray16>>8) & 0xff);
2567 *(dp++) = (
png_byte)(gray16 & 0xff);
2576 row_info->pixel_depth = (
png_byte)(row_info->channels *
2577 row_info->bit_depth);
2578 row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
2597 png_debug(1,
"in png_do_build_grayscale_palette");
2599 if (palette ==
NULL)
2630 for (i = 0, v = 0; i <
num_palette; i++, v += color_inc)
2639 #if defined(PNG_READ_DITHER_SUPPORTED) && \ 2640 defined(PNG_CORRECT_PALETTE_SUPPORTED) 2647 #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ 2648 defined(PNG_READ_GAMMA_SUPPORTED) && \ 2649 defined(PNG_FLOATING_POINT_SUPPORTED) 2650 if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND))
2656 back.
red = png_ptr->gamma_table[png_ptr->background.red];
2657 back.
green = png_ptr->gamma_table[png_ptr->background.green];
2658 back.
blue = png_ptr->gamma_table[png_ptr->background.blue];
2660 back_1.
red = png_ptr->gamma_to_1[png_ptr->background.red];
2661 back_1.
green = png_ptr->gamma_to_1[png_ptr->background.green];
2662 back_1.
blue = png_ptr->gamma_to_1[png_ptr->background.blue];
2668 g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma);
2671 || fabs(g - 1.0) < PNG_GAMMA_THRESHOLD)
2673 back.
red = png_ptr->background.red;
2674 back.
green = png_ptr->background.green;
2675 back.
blue = png_ptr->background.blue;
2680 (
png_byte)(
pow((
double)png_ptr->background.red/255,
g) *
2683 (
png_byte)(
pow((
double)png_ptr->background.green/255,
g) *
2686 (
png_byte)(
pow((
double)png_ptr->background.blue/255,
g) *
2690 g = 1.0 / png_ptr->background_gamma;
2693 (
png_byte)(
pow((
double)png_ptr->background.red/255,
g) *
2696 (
png_byte)(
pow((
double)png_ptr->background.green/255,
g) *
2699 (
png_byte)(
pow((
double)png_ptr->background.blue/255,
g) *
2709 if (i < png_ptr->
num_trans && png_ptr->trans[i] == 0)
2713 else if (i < png_ptr->
num_trans && png_ptr->trans[i] != 0xff)
2717 v = png_ptr->gamma_to_1[png_ptr->palette[
i].red];
2719 palette[
i].red = png_ptr->gamma_from_1[
w];
2721 v = png_ptr->gamma_to_1[png_ptr->palette[
i].green];
2723 palette[
i].green = png_ptr->gamma_from_1[
w];
2725 v = png_ptr->gamma_to_1[png_ptr->palette[
i].blue];
2727 palette[
i].blue = png_ptr->gamma_from_1[
w];
2758 #ifdef PNG_READ_GAMMA_SUPPORTED 2759 if (png_ptr->transformations & PNG_GAMMA)
2770 #ifdef PNG_READ_BACKGROUND_SUPPORTED 2774 #ifdef PNG_READ_BACKGROUND_SUPPORTED 2775 if (png_ptr->transformations & PNG_BACKGROUND)
2785 for (
i = 0;
i < (
int)png_ptr->num_trans;
i++)
2787 if (png_ptr->trans[
i] == 0)
2793 else if (png_ptr->trans[
i] != 0xff)
2796 png_ptr->trans[
i], back.
red);
2798 png_ptr->trans[
i], back.
green);
2800 png_ptr->trans[
i], back.
blue);
2810 if (i == (
png_byte)png_ptr->trans_values.gray)
2823 #ifdef PNG_READ_BACKGROUND_SUPPORTED 2847 #ifdef PNG_USELESS_TESTS_SUPPORTED
2853 switch (row_info->color_type)
2857 switch (row_info->bit_depth)
2863 for (i = 0; i < row_width; i++)
2866 == trans_values->gray)
2868 *sp &= (
png_byte)((0x7f7f >> (7 - shift)) & 0xff);
2884 #ifdef PNG_READ_GAMMA_SUPPORTED 2885 if (gamma_table !=
NULL)
2889 for (i = 0; i < row_width; i++)
2892 == trans_values->gray)
2894 *sp &= (
png_byte)((0x3f3f >> (6 - shift)) & 0xff);
2902 *sp &= (
png_byte)((0x3f3f >> (6 - shift)) & 0xff);
2919 for (i = 0; i < row_width; i++)
2922 == trans_values->gray)
2924 *sp &= (
png_byte)((0x3f3f >> (6 - shift)) & 0xff);
2941 #ifdef PNG_READ_GAMMA_SUPPORTED 2942 if (gamma_table !=
NULL)
2946 for (i = 0; i < row_width; i++)
2949 == trans_values->gray)
2951 *sp &= (
png_byte)((0xf0f >> (4 - shift)) & 0xff);
2958 (p << 4)] >> 4) & 0x0f);
2959 *sp &= (
png_byte)((0xf0f >> (4 - shift)) & 0xff);
2976 for (i = 0; i < row_width; i++)
2979 == trans_values->gray)
2981 *sp &= (
png_byte)((0xf0f >> (4 - shift)) & 0xff);
2998 #ifdef PNG_READ_GAMMA_SUPPORTED 2999 if (gamma_table !=
NULL)
3002 for (i = 0; i < row_width; i++, sp++)
3004 if (*sp == trans_values->gray)
3010 *sp = gamma_table[*sp];
3018 for (i = 0; i < row_width; i++, sp++)
3020 if (*sp == trans_values->gray)
3031 #ifdef PNG_READ_GAMMA_SUPPORTED 3032 if (gamma_16 !=
NULL)
3035 for (i = 0; i < row_width; i++, sp += 2)
3040 if (v == trans_values->gray)
3048 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3058 for (i = 0; i < row_width; i++, sp += 2)
3063 if (v == trans_values->gray)
3078 if (row_info->bit_depth == 8)
3080 #ifdef PNG_READ_GAMMA_SUPPORTED 3081 if (gamma_table !=
NULL)
3084 for (i = 0; i < row_width; i++, sp += 3)
3086 if (*sp == trans_values->red &&
3087 *(sp + 1) == trans_values->green &&
3088 *(sp + 2) == trans_values->blue)
3096 *sp = gamma_table[*sp];
3097 *(sp + 1) = gamma_table[*(sp + 1)];
3098 *(sp + 2) = gamma_table[*(sp + 2)];
3106 for (i = 0; i < row_width; i++, sp += 3)
3108 if (*sp == trans_values->red &&
3109 *(sp + 1) == trans_values->green &&
3110 *(sp + 2) == trans_values->blue)
3121 #ifdef PNG_READ_GAMMA_SUPPORTED 3122 if (gamma_16 !=
NULL)
3125 for (i = 0; i < row_width; i++, sp += 6)
3130 if (r == trans_values->red && g == trans_values->green &&
3131 b == trans_values->blue)
3143 png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3146 v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
3147 *(sp + 2) = (
png_byte)((v >> 8) & 0xff);
3149 v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
3150 *(sp + 4) = (
png_byte)((v >> 8) & 0xff);
3159 for (i = 0; i < row_width; i++, sp += 6)
3165 if (r == trans_values->red && g == trans_values->green &&
3166 b == trans_values->blue)
3183 if (row_info->bit_depth == 8)
3185 #ifdef PNG_READ_GAMMA_SUPPORTED 3186 if (gamma_to_1 !=
NULL && gamma_from_1 !=
NULL &&
3187 gamma_table !=
NULL)
3191 for (i = 0; i < row_width; i++, sp += 2, dp++)
3197 *dp = gamma_table[*sp];
3208 v = gamma_to_1[*sp];
3210 *dp = gamma_from_1[
w];
3219 for (i = 0; i < row_width; i++, sp += 2, dp++)
3227 #ifdef PNG_READ_GAMMA_SUPPORTED 3244 #ifdef PNG_READ_GAMMA_SUPPORTED 3245 if (gamma_16 !=
NULL && gamma_16_from_1 !=
NULL &&
3246 gamma_16_to_1 !=
NULL)
3250 for (i = 0; i < row_width; i++, sp += 4, dp += 2)
3258 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3262 #ifdef PNG_READ_GAMMA_SUPPORTED 3272 #ifdef PNG_READ_GAMMA_SUPPORTED 3277 g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
3279 w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];
3291 for (i = 0; i < row_width; i++, sp += 4, dp += 2)
3298 #ifdef PNG_READ_GAMMA_SUPPORTED 3307 #ifdef PNG_READ_GAMMA_SUPPORTED 3326 if (row_info->bit_depth == 8)
3328 #ifdef PNG_READ_GAMMA_SUPPORTED 3329 if (gamma_to_1 !=
NULL && gamma_from_1 !=
NULL &&
3330 gamma_table !=
NULL)
3334 for (i = 0; i < row_width; i++, sp += 4, dp += 3)
3340 *dp = gamma_table[*sp];
3341 *(dp + 1) = gamma_table[*(sp + 1)];
3342 *(dp + 2) = gamma_table[*(sp + 2)];
3355 v = gamma_to_1[*sp];
3357 *dp = gamma_from_1[
w];
3358 v = gamma_to_1[*(sp + 1)];
3360 *(dp + 1) = gamma_from_1[w];
3361 v = gamma_to_1[*(sp + 2)];
3363 *(dp + 2) = gamma_from_1[w];
3372 for (i = 0; i < row_width; i++, sp += 4, dp += 3)
3379 *(dp + 1) = *(sp + 1);
3380 *(dp + 2) = *(sp + 2);
3401 #ifdef PNG_READ_GAMMA_SUPPORTED 3402 if (gamma_16 !=
NULL && gamma_16_from_1 !=
NULL &&
3403 gamma_16_to_1 !=
NULL)
3407 for (i = 0; i < row_width; i++, sp += 8, dp += 6)
3415 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3418 v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
3419 *(dp + 2) = (
png_byte)((v >> 8) & 0xff);
3421 v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
3422 *(dp + 4) = (
png_byte)((v >> 8) & 0xff);
3439 v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
3441 x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
3444 v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
3446 x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
3447 *(dp + 2) = (
png_byte)((x >> 8) & 0xff);
3449 v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
3451 x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8];
3452 *(dp + 4) = (
png_byte)((x >> 8) & 0xff);
3462 for (i = 0; i < row_width; i++, sp += 8, dp += 6)
3493 *(dp + 2) = (
png_byte)((v >> 8) & 0xff);
3496 *(dp + 4) = (
png_byte)((v >> 8) & 0xff);
3509 row_info->channels--;
3510 row_info->pixel_depth = (
png_byte)(row_info->channels *
3511 row_info->bit_depth);
3512 row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
3518 #ifdef PNG_READ_GAMMA_SUPPORTED 3537 #ifdef PNG_USELESS_TESTS_SUPPORTED
3540 ((row_info->bit_depth <= 8 && gamma_table !=
NULL) ||
3541 (row_info->bit_depth == 16 && gamma_16_table !=
NULL)))
3543 switch (row_info->color_type)
3547 if (row_info->bit_depth == 8)
3550 for (i = 0; i < row_width; i++)
3552 *sp = gamma_table[*sp];
3554 *sp = gamma_table[*sp];
3556 *sp = gamma_table[*sp];
3563 for (i = 0; i < row_width; i++)
3567 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3571 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3575 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3586 if (row_info->bit_depth == 8)
3589 for (i = 0; i < row_width; i++)
3591 *sp = gamma_table[*sp];
3593 *sp = gamma_table[*sp];
3595 *sp = gamma_table[*sp];
3603 for (i = 0; i < row_width; i++)
3605 png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3609 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3613 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3624 if (row_info->bit_depth == 8)
3627 for (i = 0; i < row_width; i++)
3629 *sp = gamma_table[*sp];
3636 for (i = 0; i < row_width; i++)
3638 png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3649 if (row_info->bit_depth == 2)
3652 for (i = 0; i < row_width; i += 4)
3660 ((((
int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)|
3661 ((((
int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)|
3663 ((((
int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) ));
3668 if (row_info->bit_depth == 4)
3671 for (i = 0; i < row_width; i += 2)
3673 int msb = *sp & 0xf0;
3674 int lsb = *sp & 0x0f;
3676 *sp = (
png_byte)((((
int)gamma_table[msb | (msb >> 4)]) & 0xf0)
3677 | (((
int)gamma_table[(lsb << 4) | lsb]) >> 4));
3682 else if (row_info->bit_depth == 8)
3685 for (i = 0; i < row_width; i++)
3687 *sp = gamma_table[*sp];
3692 else if (row_info->bit_depth == 16)
3695 for (i = 0; i < row_width; i++)
3697 png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3710 #ifdef PNG_READ_EXPAND_SUPPORTED 3723 png_debug(1,
"in png_do_expand_palette");
3726 #ifdef PNG_USELESS_TESTS_SUPPORTED
3731 if (row_info->bit_depth < 8)
3733 switch (row_info->bit_depth)
3737 sp = row + (
png_size_t)((row_width - 1) >> 3);
3739 shift = 7 - (
int)((row_width + 7) & 0x07);
3740 for (i = 0; i < row_width; i++)
3742 if ((*sp >> shift) & 0x01)
3761 sp = row + (
png_size_t)((row_width - 1) >> 2);
3763 shift = (
int)((3 - ((row_width + 3) & 0x03)) << 1);
3764 for (i = 0; i < row_width; i++)
3766 value = (*sp >> shift) & 0x03;
3783 sp = row + (
png_size_t)((row_width - 1) >> 1);
3785 shift = (
int)((row_width & 0x01) << 2);
3786 for (i = 0; i < row_width; i++)
3788 value = (*sp >> shift) & 0x0f;
3803 row_info->bit_depth = 8;
3804 row_info->pixel_depth = 8;
3805 row_info->rowbytes = row_width;
3807 switch (row_info->bit_depth)
3816 for (i = 0; i < row_width; i++)
3822 *dp-- = palette[*sp].blue;
3823 *dp-- = palette[*sp].green;
3824 *dp-- = palette[*sp].red;
3827 row_info->bit_depth = 8;
3828 row_info->pixel_depth = 32;
3829 row_info->rowbytes = row_width * 4;
3830 row_info->color_type = 6;
3831 row_info->channels = 4;
3838 for (i = 0; i < row_width; i++)
3840 *dp-- = palette[*sp].blue;
3841 *dp-- = palette[*sp].green;
3842 *dp-- = palette[*sp].red;
3846 row_info->bit_depth = 8;
3847 row_info->pixel_depth = 24;
3848 row_info->rowbytes = row_width * 3;
3849 row_info->color_type = 2;
3850 row_info->channels = 3;
3872 #ifdef PNG_USELESS_TESTS_SUPPORTED 3873 if (row !=
NULL && row_info !=
NULL)
3880 if (row_info->bit_depth < 8)
3882 switch (row_info->bit_depth)
3887 sp = row + (
png_size_t)((row_width - 1) >> 3);
3889 shift = 7 - (
int)((row_width + 7) & 0x07);
3890 for (i = 0; i < row_width; i++)
3892 if ((*sp >> shift) & 0x01)
3912 sp = row + (
png_size_t)((row_width - 1) >> 2);
3914 shift = (
int)((3 - ((row_width + 3) & 0x03)) << 1);
3915 for (i = 0; i < row_width; i++)
3917 value = (*sp >> shift) & 0x03;
3918 *dp = (
png_byte)(value | (value << 2) | (value << 4) |
3936 sp = row + (
png_size_t)((row_width - 1) >> 1);
3938 shift = (
int)((1 - ((row_width + 1) & 0x01)) << 2);
3939 for (i = 0; i < row_width; i++)
3941 value = (*sp >> shift) & 0x0f;
3942 *dp = (
png_byte)(value | (value << 4));
3957 row_info->bit_depth = 8;
3958 row_info->pixel_depth = 8;
3959 row_info->rowbytes = row_width;
3962 if (trans_value !=
NULL)
3964 if (row_info->bit_depth == 8)
3969 for (i = 0; i < row_width; i++)
3979 else if (row_info->bit_depth == 16)
3981 png_byte gray_high = (gray >> 8) & 0xff;
3983 sp = row + row_info->rowbytes - 1;
3984 dp = row + (row_info->rowbytes << 1) - 1;
3985 for (i = 0; i < row_width; i++)
3987 if (*(sp - 1) == gray_high && *(sp) == gray_low)
4003 row_info->channels = 2;
4004 row_info->pixel_depth = (
png_byte)(row_info->bit_depth << 1);
4005 row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
4011 if (row_info->bit_depth == 8)
4016 sp = row + (
png_size_t)row_info->rowbytes - 1;
4018 for (i = 0; i < row_width; i++)
4020 if (*(sp - 2) == red && *(sp - 1) == green && *(sp) ==
blue)
4029 else if (row_info->bit_depth == 16)
4031 png_byte red_high = (trans_value->red >> 8) & 0xff;
4032 png_byte green_high = (trans_value->green >> 8) & 0xff;
4033 png_byte blue_high = (trans_value->blue >> 8) & 0xff;
4034 png_byte red_low = trans_value->red & 0xff;
4035 png_byte green_low = trans_value->green & 0xff;
4036 png_byte blue_low = trans_value->blue & 0xff;
4037 sp = row + row_info->rowbytes - 1;
4039 for (i = 0; i < row_width; i++)
4041 if (*(sp - 5) == red_high &&
4042 *(sp - 4) == red_low &&
4043 *(sp - 3) == green_high &&
4044 *(sp - 2) == green_low &&
4045 *(sp - 1) == blue_high &&
4065 row_info->channels = 4;
4066 row_info->pixel_depth = (
png_byte)(row_info->bit_depth << 2);
4067 row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
4073 #ifdef PNG_READ_DITHER_SUPPORTED 4084 #ifdef PNG_USELESS_TESTS_SUPPORTED 4085 if (row !=
NULL && row_info !=
NULL)
4089 palette_lookup && row_info->bit_depth == 8)
4094 for (i = 0; i < row_width; i++)
4107 p = (((r >> (8 - PNG_DITHER_RED_BITS)) &
4108 ((1 << PNG_DITHER_RED_BITS) - 1)) <<
4109 (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) |
4110 (((g >> (8 - PNG_DITHER_GREEN_BITS)) &
4111 ((1 << PNG_DITHER_GREEN_BITS) - 1)) <<
4112 (PNG_DITHER_BLUE_BITS)) |
4113 ((b >> (8 - PNG_DITHER_BLUE_BITS)) &
4114 ((1 << PNG_DITHER_BLUE_BITS) - 1));
4116 *dp++ = palette_lookup[
p];
4119 row_info->channels = 1;
4120 row_info->pixel_depth = row_info->bit_depth;
4121 row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
4124 palette_lookup !=
NULL && row_info->bit_depth == 8)
4129 for (i = 0; i < row_width; i++)
4136 p = (((r >> (8 - PNG_DITHER_RED_BITS)) &
4137 ((1 << PNG_DITHER_RED_BITS) - 1)) <<
4138 (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) |
4139 (((g >> (8 - PNG_DITHER_GREEN_BITS)) &
4140 ((1 << PNG_DITHER_GREEN_BITS) - 1)) <<
4141 (PNG_DITHER_BLUE_BITS)) |
4142 ((b >> (8 - PNG_DITHER_BLUE_BITS)) &
4143 ((1 << PNG_DITHER_BLUE_BITS) - 1));
4145 *dp++ = palette_lookup[
p];
4148 row_info->channels = 1;
4149 row_info->pixel_depth = row_info->bit_depth;
4150 row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
4153 dither_lookup && row_info->bit_depth == 8)
4156 for (i = 0; i < row_width; i++, sp++)
4158 *sp = dither_lookup[*sp];
4165 #ifdef PNG_FLOATING_POINT_SUPPORTED 4166 #ifdef PNG_READ_GAMMA_SUPPORTED 4167 static PNG_CONST int png_gamma_shift[] =
4168 {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00};
4206 png_debug(1,
"in png_build_gamma_table");
4208 if (png_ptr->bit_depth <= 8)
4213 if (png_ptr->screen_gamma > .000001)
4214 g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
4222 for (i = 0; i < 256; i++)
4224 png_ptr->gamma_table[
i] = (
png_byte)(
pow((
double)i / 255.0,
4228 #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ 4229 defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) 4230 if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY))
4233 g = 1.0 / (png_ptr->gamma);
4238 for (i = 0; i < 256; i++)
4240 png_ptr->gamma_to_1[
i] = (
png_byte)(
pow((
double)i / 255.0,
4248 if (png_ptr->screen_gamma > 0.000001)
4249 g = 1.0 / png_ptr->screen_gamma;
4254 for (i = 0; i < 256; i++)
4256 png_ptr->gamma_from_1[
i] = (
png_byte)(
pow((
double)i / 255.0,
4266 int i, j, shift,
num;
4272 sig_bit = (
int)png_ptr->sig_bit.red;
4274 if ((
int)png_ptr->sig_bit.green >
sig_bit)
4275 sig_bit = png_ptr->sig_bit.green;
4277 if ((
int)png_ptr->sig_bit.blue >
sig_bit)
4278 sig_bit = png_ptr->sig_bit.blue;
4282 sig_bit = (
int)png_ptr->sig_bit.gray;
4291 if (png_ptr->transformations & PNG_16_TO_8)
4293 if (shift < (16 - PNG_MAX_GAMMA_8))
4294 shift = (16 - PNG_MAX_GAMMA_8);
4303 png_ptr->gamma_shift = (
png_byte)shift;
4305 num = (1 << (8 - shift));
4307 if (png_ptr->screen_gamma > .000001)
4308 g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
4315 if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
4320 for (i = 0; i <
num; i++)
4328 for (i = 0; i < 256; i++)
4330 fout = ((double)i + 0.5) / 256.0;
4335 png_ptr->gamma_16_table[(
int)(last & (0xff >> shift))]
4343 png_ptr->gamma_16_table[(
int)(last & (0xff >> shift))]
4344 [(
int)(last >> (8 - shift))] = (
png_uint_16)65535L;
4350 for (i = 0; i <
num; i++)
4357 for (j = 0; j < 256; j++)
4359 png_ptr->gamma_16_table[
i][j] =
4361 65535.0, g) * 65535.0 + .5);
4366 #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ 4367 defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) 4368 if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY))
4371 g = 1.0 / (png_ptr->gamma);
4376 for (i = 0; i <
num; i++)
4383 for (j = 0; j < 256; j++)
4385 png_ptr->gamma_16_to_1[
i][j] =
4387 65535.0, g) * 65535.0 + .5);
4391 if (png_ptr->screen_gamma > 0.000001)
4392 g = 1.0 / png_ptr->screen_gamma;
4400 for (i = 0; i <
num; i++)
4408 for (j = 0; j < 256; j++)
4410 png_ptr->gamma_16_from_1[
i][j] =
4412 65535.0, g) * 65535.0 + .5);
4423 #ifdef PNG_MNG_FEATURES_SUPPORTED 4428 png_debug(1,
"in png_do_read_intrapixel");
4431 #ifdef PNG_USELESS_TESTS_SUPPORTED
4436 int bytes_per_pixel;
4438 if (row_info->bit_depth == 8)
4444 bytes_per_pixel = 3;
4447 bytes_per_pixel = 4;
4452 for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
4454 *(rp) = (
png_byte)((256 + *rp + *(rp+1))&0xff);
4455 *(rp+2) = (
png_byte)((256 + *(rp+2) + *(rp+1))&0xff);
4458 else if (row_info->bit_depth == 16)
4464 bytes_per_pixel = 6;
4467 bytes_per_pixel = 8;
4472 for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
4479 *(rp ) = (
png_byte)((red >> 8) & 0xff);
4481 *(rp+4) = (
png_byte)((blue >> 8) & 0xff);
void png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
#define PNG_CRC_NO_CHANGE
struct png_dsort_struct png_dsort
#define PNG_BACKGROUND_GAMMA_UNIQUE
void png_do_packswap(png_row_infop row_info, png_bytep row)
for(n=1;n< outline->n_points;n++)
void PNGAPI png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)
png_color_16p int int double background_gamma
png_colorp int int png_uint_16p int full_dither
void PNGAPI png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
void png_do_background(png_row_infop row_info, png_bytep row, png_color_16p trans_values, png_color_16p background, png_color_16p background_1, png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1, png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1, png_uint_16pp gamma_16_to_1, int gamma_shift)
GLboolean GLboolean GLboolean GLboolean a
void png_do_gamma(png_row_infop row_info, png_bytep row, png_bytep gamma_table, png_uint_16pp gamma_16_table, int gamma_shift)
void png_do_invert(png_row_infop row_info, png_bytep row)
void png_do_expand(png_row_infop row_info, png_bytep row, png_color_16p trans_value)
#define png_composite(composite, fg, alpha, bg)
void png_do_read_filler(png_row_infop row_info, png_bytep row, png_uint_32 filler, png_uint_32 flags)
png_colorp int num_palette
#define PNG_BACKGROUND_GAMMA_SCREEN
png_voidp png_calloc(png_structp png_ptr, png_uint_32 size)
void PNGAPI png_set_palette_to_rgb(png_structp png_ptr)
png_color_16 FAR * png_color_16p
void png_build_gamma_table(png_structp png_ptr)
#define PNG_COLOR_TYPE_RGB
#define PNG_COLOR_TYPE_GRAY_ALPHA
png_infop png_color_16p * background
void png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
#define PNG_COLOR_TYPE_PALETTE
png_colorp int int png_uint_16p histogram
void PNGAPI png_set_dither(png_structp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_uint_16p histogram, int full_dither)
#define PNG_CRC_WARN_DISCARD
void PNGAPI png_set_background(png_structp png_ptr, png_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma)
void png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
GLint GLint GLint GLint GLint x
#define PNG_COLOR_TYPE_RGB_ALPHA
void png_do_read_transformations(png_structp png_ptr)
png_color_16p int int need_expand
void PNGAPI png_set_strip_16(png_structp png_ptr)
GLboolean GLboolean GLboolean b
void png_do_chop(png_row_infop row_info, png_bytep row)
#define PNG_BACKGROUND_GAMMA_FILE
int png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
png_infop png_bytep * trans
void PNGAPI png_set_gray_1_2_4_to_8(png_structp png_ptr)
GLenum GLenum GLvoid * row
png_infop png_bytep int png_color_16p * trans_values
void png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
void png_init_read_transformations(png_structp png_ptr)
void png_do_dither(png_row_infop row_info, png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup)
void PNGAPI png_build_grayscale_palette(int bit_depth, png_colorp palette)
void png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
png_struct FAR * png_structp
#define PNG_READ_BACKGROUND_SUPPORTED
#define png_error(s1, s2)
#define PNG_COLOR_MASK_COLOR
png_dsort FAR *FAR * png_dsortpp
void png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
unsigned short png_uint_16
GLdouble GLdouble GLdouble r
#define PNG_CRC_QUIET_USE
png_infop png_bytep int * num_trans
#define PNG_COLOR_TYPE_GRAY
void PNGAPI png_warning(png_structp png_ptr, png_const_charp warning_message)
png_dsort FAR * png_dsortp
void png_do_bgr(png_row_infop row_info, png_bytep row)
png_uint_16 FAR * png_uint_16p
void PNGAPI png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
GLsizei GLsizei GLfloat distance
GLsizei const GLfloat * value
void PNGAPI png_set_strip_alpha(png_structp png_ptr)
void png_do_expand_palette(png_row_infop row_info, png_bytep row, png_colorp palette, png_bytep trans, int num_trans)
png_infop double * file_gamma
if(!abbox) return FT_THROW(Invalid_Argument)
#define PNG_CRC_ERROR_QUIT
void png_do_unpack(png_row_infop row_info, png_bytep row)
png_uint_16 FAR *FAR * png_uint_16pp
#define PNG_COLOR_MASK_ALPHA
GLubyte GLubyte GLubyte GLubyte w
void png_do_swap(png_row_infop row_info, png_bytep row)
void PNGAPI png_set_expand(png_structp png_ptr)
png_color_8 FAR * png_color_8p
#define png_composite_16(composite, fg, alpha, bg)
void PNGAPI png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
void PNGAPI png_set_tRNS_to_alpha(png_structp png_ptr)
png_int_32 png_fixed_point
png_color_16p background_color
#define PNG_BACKGROUND_GAMMA_UNKNOWN
png_colorp int int maximum_colors
void PNGAPI png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr read_user_transform_fn)
unsigned long png_uint_32
png_row_info FAR * png_row_infop
void png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
void PNGAPI png_free(png_structp png_ptr, png_voidp ptr)
png_color_16p int background_gamma_code
void PNGAPI png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, double green)
png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size)
png_voidp PNGAPI png_malloc_warn(png_structp png_ptr, png_uint_32 size)
void PNGAPI png_set_gray_to_rgb(png_structp png_ptr)
png_user_transform_ptr read_user_transform_fn
#define PNG_READ_GAMMA_SUPPORTED
png_infop png_color_8p * sig_bit
png_color FAR * png_colorp