Lines Matching refs:png_ptr
25 png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) in png_set_crc_action() argument
29 if (png_ptr == NULL) in png_set_crc_action()
39 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; in png_set_crc_action()
40 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; in png_set_crc_action()
44 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; in png_set_crc_action()
45 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | in png_set_crc_action()
50 png_warning(png_ptr, in png_set_crc_action()
56 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; in png_set_crc_action()
67 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
68 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; in png_set_crc_action()
72 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
73 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | in png_set_crc_action()
78 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
79 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; in png_set_crc_action()
86 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
94 png_set_background_fixed(png_structp png_ptr, in png_set_background_fixed() argument
100 if (png_ptr == NULL) in png_set_background_fixed()
105 png_warning(png_ptr, "Application must supply a known background gamma"); in png_set_background_fixed()
109 png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA; in png_set_background_fixed()
110 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_set_background_fixed()
111 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_set_background_fixed()
113 png_memcpy(&(png_ptr->background), background_color, in png_set_background_fixed()
115 png_ptr->background_gamma = background_gamma; in png_set_background_fixed()
116 png_ptr->background_gamma_type = (png_byte)(background_gamma_code); in png_set_background_fixed()
118 png_ptr->transformations |= PNG_BACKGROUND_EXPAND; in png_set_background_fixed()
120 png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; in png_set_background_fixed()
125 png_set_background(png_structp png_ptr, in png_set_background() argument
129 png_set_background_fixed(png_ptr, background_color, background_gamma_code, in png_set_background()
130 need_expand, png_fixed(png_ptr, background_gamma, "png_set_background")); in png_set_background()
141 png_set_scale_16(png_structp png_ptr) in png_set_scale_16() argument
145 if (png_ptr == NULL) in png_set_scale_16()
148 png_ptr->transformations |= PNG_SCALE_16_TO_8; in png_set_scale_16()
155 png_set_strip_16(png_structp png_ptr) in png_set_strip_16() argument
159 if (png_ptr == NULL) in png_set_strip_16()
162 png_ptr->transformations |= PNG_16_TO_8; in png_set_strip_16()
168 png_set_strip_alpha(png_structp png_ptr) in png_set_strip_alpha() argument
172 if (png_ptr == NULL) in png_set_strip_alpha()
175 png_ptr->transformations |= PNG_STRIP_ALPHA; in png_set_strip_alpha()
181 translate_gamma_flags(png_structp png_ptr, png_fixed_point output_gamma, in translate_gamma_flags() argument
196 png_ptr->flags |= PNG_FLAG_ASSUME_sRGB; in translate_gamma_flags()
218 convert_gamma_value(png_structp png_ptr, double output_gamma) in convert_gamma_value() argument
234 png_fixed_error(png_ptr, "gamma value"); in convert_gamma_value()
243 png_set_alpha_mode_fixed(png_structp png_ptr, int mode, in png_set_alpha_mode_fixed() argument
251 if (png_ptr == NULL) in png_set_alpha_mode_fixed()
254 output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/); in png_set_alpha_mode_fixed()
263 png_error(png_ptr, "output gamma out of expected range"); in png_set_alpha_mode_fixed()
290 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_set_alpha_mode_fixed()
291 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_set_alpha_mode_fixed()
296 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_set_alpha_mode_fixed()
297 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_set_alpha_mode_fixed()
304 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_set_alpha_mode_fixed()
305 png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA; in png_set_alpha_mode_fixed()
311 png_ptr->transformations |= PNG_ENCODE_ALPHA; in png_set_alpha_mode_fixed()
312 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_set_alpha_mode_fixed()
316 png_error(png_ptr, "invalid alpha mode"); in png_set_alpha_mode_fixed()
323 if (png_ptr->gamma == 0) in png_set_alpha_mode_fixed()
324 png_ptr->gamma = file_gamma; in png_set_alpha_mode_fixed()
327 png_ptr->screen_gamma = output_gamma; in png_set_alpha_mode_fixed()
335 png_memset(&png_ptr->background, 0, sizeof png_ptr->background); in png_set_alpha_mode_fixed()
336 png_ptr->background_gamma = png_ptr->gamma; /* just in case */ in png_set_alpha_mode_fixed()
337 png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE; in png_set_alpha_mode_fixed()
338 png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; in png_set_alpha_mode_fixed()
340 if (png_ptr->transformations & PNG_COMPOSE) in png_set_alpha_mode_fixed()
341 png_error(png_ptr, in png_set_alpha_mode_fixed()
344 png_ptr->transformations |= PNG_COMPOSE; in png_set_alpha_mode_fixed()
348 png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED; in png_set_alpha_mode_fixed()
353 png_set_alpha_mode(png_structp png_ptr, int mode, double output_gamma) in png_set_alpha_mode() argument
355 png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr, in png_set_alpha_mode()
381 png_set_quantize(png_structp png_ptr, png_colorp palette, in png_set_quantize() argument
387 if (png_ptr == NULL) in png_set_quantize()
390 png_ptr->transformations |= PNG_QUANTIZE; in png_set_quantize()
396 png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, in png_set_quantize()
399 png_ptr->quantize_index[i] = (png_byte)i; in png_set_quantize()
413 png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, in png_set_quantize()
418 png_ptr->quantize_sort[i] = (png_byte)i; in png_set_quantize()
435 if (histogram[png_ptr->quantize_sort[j]] in png_set_quantize()
436 < histogram[png_ptr->quantize_sort[j + 1]]) in png_set_quantize()
440 t = png_ptr->quantize_sort[j]; in png_set_quantize()
441 png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1]; in png_set_quantize()
442 png_ptr->quantize_sort[j + 1] = t; in png_set_quantize()
461 if ((int)png_ptr->quantize_sort[i] >= maximum_colors) in png_set_quantize()
465 while ((int)png_ptr->quantize_sort[j] >= maximum_colors); in png_set_quantize()
481 if ((int)png_ptr->quantize_sort[i] >= maximum_colors) in png_set_quantize()
487 while ((int)png_ptr->quantize_sort[j] >= maximum_colors); in png_set_quantize()
493 png_ptr->quantize_index[j] = (png_byte)i; in png_set_quantize()
494 png_ptr->quantize_index[i] = (png_byte)j; in png_set_quantize()
501 if ((int)png_ptr->quantize_index[i] >= maximum_colors) in png_set_quantize()
506 d_index = png_ptr->quantize_index[i]; in png_set_quantize()
521 png_ptr->quantize_index[i] = (png_byte)min_k; in png_set_quantize()
525 png_free(png_ptr, png_ptr->quantize_sort); in png_set_quantize()
526 png_ptr->quantize_sort = NULL; in png_set_quantize()
547 png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, in png_set_quantize()
549 png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, in png_set_quantize()
555 png_ptr->index_to_palette[i] = (png_byte)i; in png_set_quantize()
556 png_ptr->palette_to_index[i] = (png_byte)i; in png_set_quantize()
559 hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 * in png_set_quantize()
589 t = (png_dsortp)png_malloc_warn(png_ptr, in png_set_quantize()
614 if ((int)png_ptr->index_to_palette[p->left] in png_set_quantize()
616 (int)png_ptr->index_to_palette[p->right] in png_set_quantize()
633 palette[png_ptr->index_to_palette[j]] in png_set_quantize()
641 if (png_ptr->quantize_index[k] == in png_set_quantize()
642 png_ptr->index_to_palette[j]) in png_set_quantize()
643 png_ptr->quantize_index[k] = in png_set_quantize()
644 png_ptr->index_to_palette[next_j]; in png_set_quantize()
646 if ((int)png_ptr->quantize_index[k] == in png_set_quantize()
648 png_ptr->quantize_index[k] = in png_set_quantize()
649 png_ptr->index_to_palette[j]; in png_set_quantize()
653 png_ptr->index_to_palette[png_ptr->palette_to_index in png_set_quantize()
654 [num_new_palette]] = png_ptr->index_to_palette[j]; in png_set_quantize()
656 png_ptr->palette_to_index[png_ptr->index_to_palette[j]] in png_set_quantize()
657 = png_ptr->palette_to_index[num_new_palette]; in png_set_quantize()
659 png_ptr->index_to_palette[j] = in png_set_quantize()
662 png_ptr->palette_to_index[num_new_palette] = in png_set_quantize()
681 png_free(png_ptr, p); in png_set_quantize()
689 png_free(png_ptr, hash); in png_set_quantize()
690 png_free(png_ptr, png_ptr->palette_to_index); in png_set_quantize()
691 png_free(png_ptr, png_ptr->index_to_palette); in png_set_quantize()
692 png_ptr->palette_to_index = NULL; in png_set_quantize()
693 png_ptr->index_to_palette = NULL; in png_set_quantize()
697 if (png_ptr->palette == NULL) in png_set_quantize()
699 png_ptr->palette = palette; in png_set_quantize()
701 png_ptr->num_palette = (png_uint_16)num_palette; in png_set_quantize()
714 png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr, in png_set_quantize()
717 distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * in png_set_quantize()
755 png_ptr->palette_lookup[d_index] = (png_byte)i; in png_set_quantize()
762 png_free(png_ptr, distance); in png_set_quantize()
769 png_set_gamma_fixed(png_structp png_ptr, png_fixed_point scrn_gamma, in png_set_gamma_fixed() argument
774 if (png_ptr == NULL) in png_set_gamma_fixed()
778 scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/); in png_set_gamma_fixed()
779 file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/); in png_set_gamma_fixed()
793 png_error(png_ptr, "invalid file gamma in png_set_gamma"); in png_set_gamma_fixed()
796 png_error(png_ptr, "invalid screen gamma in png_set_gamma"); in png_set_gamma_fixed()
803 png_ptr->gamma = file_gamma; in png_set_gamma_fixed()
804 png_ptr->screen_gamma = scrn_gamma; in png_set_gamma_fixed()
809 png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) in png_set_gamma() argument
811 png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma), in png_set_gamma()
812 convert_gamma_value(png_ptr, file_gamma)); in png_set_gamma()
823 png_set_expand(png_structp png_ptr) in png_set_expand() argument
827 if (png_ptr == NULL) in png_set_expand()
830 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_expand()
831 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_expand()
854 png_set_palette_to_rgb(png_structp png_ptr) in png_set_palette_to_rgb() argument
858 if (png_ptr == NULL) in png_set_palette_to_rgb()
861 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_palette_to_rgb()
862 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_palette_to_rgb()
867 png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) in png_set_expand_gray_1_2_4_to_8() argument
871 if (png_ptr == NULL) in png_set_expand_gray_1_2_4_to_8()
874 png_ptr->transformations |= PNG_EXPAND; in png_set_expand_gray_1_2_4_to_8()
875 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_expand_gray_1_2_4_to_8()
882 png_set_tRNS_to_alpha(png_structp png_ptr) in png_set_tRNS_to_alpha() argument
886 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_tRNS_to_alpha()
887 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_tRNS_to_alpha()
896 png_set_expand_16(png_structp png_ptr) in png_set_expand_16() argument
900 if (png_ptr == NULL) in png_set_expand_16()
903 png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_expand_16()
904 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_expand_16()
907 png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED; in png_set_expand_16()
913 png_set_gray_to_rgb(png_structp png_ptr) in png_set_gray_to_rgb() argument
917 if (png_ptr != NULL) in png_set_gray_to_rgb()
920 png_set_expand_gray_1_2_4_to_8(png_ptr); in png_set_gray_to_rgb()
921 png_ptr->transformations |= PNG_GRAY_TO_RGB; in png_set_gray_to_rgb()
922 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_gray_to_rgb()
929 png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, in png_set_rgb_to_gray_fixed() argument
934 if (png_ptr == NULL) in png_set_rgb_to_gray_fixed()
940 png_ptr->transformations |= PNG_RGB_TO_GRAY; in png_set_rgb_to_gray_fixed()
944 png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; in png_set_rgb_to_gray_fixed()
948 png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; in png_set_rgb_to_gray_fixed()
952 png_error(png_ptr, "invalid error action to rgb_to_gray"); in png_set_rgb_to_gray_fixed()
955 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_set_rgb_to_gray_fixed()
957 png_ptr->transformations |= PNG_EXPAND; in png_set_rgb_to_gray_fixed()
960 png_warning(png_ptr, in png_set_rgb_to_gray_fixed()
963 png_ptr->transformations &= ~PNG_RGB_TO_GRAY; in png_set_rgb_to_gray_fixed()
979 png_ptr->rgb_to_gray_red_coeff = red_int; in png_set_rgb_to_gray_fixed()
980 png_ptr->rgb_to_gray_green_coeff = green_int; in png_set_rgb_to_gray_fixed()
981 png_ptr->rgb_to_gray_coefficients_set = 1; in png_set_rgb_to_gray_fixed()
987 png_warning(png_ptr, in png_set_rgb_to_gray_fixed()
996 if (png_ptr->rgb_to_gray_red_coeff == 0 && in png_set_rgb_to_gray_fixed()
997 png_ptr->rgb_to_gray_green_coeff == 0) in png_set_rgb_to_gray_fixed()
999 png_ptr->rgb_to_gray_red_coeff = 6968; in png_set_rgb_to_gray_fixed()
1000 png_ptr->rgb_to_gray_green_coeff = 23434; in png_set_rgb_to_gray_fixed()
1013 png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, in png_set_rgb_to_gray() argument
1016 if (png_ptr == NULL) in png_set_rgb_to_gray()
1019 png_set_rgb_to_gray_fixed(png_ptr, error_action, in png_set_rgb_to_gray()
1020 png_fixed(png_ptr, red, "rgb to gray red coefficient"), in png_set_rgb_to_gray()
1021 png_fixed(png_ptr, green, "rgb to gray green coefficient")); in png_set_rgb_to_gray()
1030 png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr in png_set_read_user_transform_fn() argument
1035 if (png_ptr == NULL) in png_set_read_user_transform_fn()
1039 png_ptr->transformations |= PNG_USER_TRANSFORM; in png_set_read_user_transform_fn()
1040 png_ptr->read_user_transform_fn = read_user_transform_fn; in png_set_read_user_transform_fn()
1077 png_init_palette_transformations(png_structp png_ptr) in png_init_palette_transformations() argument
1090 if (png_ptr->num_trans > 0) in png_init_palette_transformations()
1095 for (i=0; i<png_ptr->num_trans; ++i) in png_init_palette_transformations()
1096 if (png_ptr->trans_alpha[i] == 255) in png_init_palette_transformations()
1098 else if (png_ptr->trans_alpha[i] == 0) in png_init_palette_transformations()
1111 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_init_palette_transformations()
1112 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_init_palette_transformations()
1115 png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); in png_init_palette_transformations()
1127 if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && in png_init_palette_transformations()
1128 (png_ptr->transformations & PNG_EXPAND)) in png_init_palette_transformations()
1131 png_ptr->background.red = in png_init_palette_transformations()
1132 png_ptr->palette[png_ptr->background.index].red; in png_init_palette_transformations()
1133 png_ptr->background.green = in png_init_palette_transformations()
1134 png_ptr->palette[png_ptr->background.index].green; in png_init_palette_transformations()
1135 png_ptr->background.blue = in png_init_palette_transformations()
1136 png_ptr->palette[png_ptr->background.index].blue; in png_init_palette_transformations()
1139 if (png_ptr->transformations & PNG_INVERT_ALPHA) in png_init_palette_transformations()
1141 if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) in png_init_palette_transformations()
1146 int i, istop = png_ptr->num_trans; in png_init_palette_transformations()
1149 png_ptr->trans_alpha[i] = (png_byte)(255 - in png_init_palette_transformations()
1150 png_ptr->trans_alpha[i]); in png_init_palette_transformations()
1160 png_init_rgb_transformations(png_structp png_ptr) in png_init_rgb_transformations() argument
1166 int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0; in png_init_rgb_transformations()
1167 int input_has_transparency = png_ptr->num_trans > 0; in png_init_rgb_transformations()
1177 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_init_rgb_transformations()
1178 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_init_rgb_transformations()
1182 png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); in png_init_rgb_transformations()
1194 if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && in png_init_rgb_transformations()
1195 (png_ptr->transformations & PNG_EXPAND) && in png_init_rgb_transformations()
1196 !(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) in png_init_rgb_transformations()
1201 int gray = png_ptr->background.gray; in png_init_rgb_transformations()
1202 int trans_gray = png_ptr->trans_color.gray; in png_init_rgb_transformations()
1204 switch (png_ptr->bit_depth) in png_init_rgb_transformations()
1231 png_ptr->background.red = png_ptr->background.green = in png_init_rgb_transformations()
1232 png_ptr->background.blue = (png_uint_16)gray; in png_init_rgb_transformations()
1234 if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) in png_init_rgb_transformations()
1236 png_ptr->trans_color.red = png_ptr->trans_color.green = in png_init_rgb_transformations()
1237 png_ptr->trans_color.blue = (png_uint_16)trans_gray; in png_init_rgb_transformations()
1245 png_init_read_transformations(png_structp png_ptr) in png_init_read_transformations() argument
1270 if (png_ptr->gamma != 0) /* has been set */ in png_init_read_transformations()
1272 if (png_ptr->screen_gamma != 0) /* screen set too */ in png_init_read_transformations()
1273 gamma_correction = png_gamma_threshold(png_ptr->gamma, in png_init_read_transformations()
1274 png_ptr->screen_gamma); in png_init_read_transformations()
1280 png_ptr->screen_gamma = png_reciprocal(png_ptr->gamma); in png_init_read_transformations()
1283 else if (png_ptr->screen_gamma != 0) in png_init_read_transformations()
1289 png_ptr->gamma = png_reciprocal(png_ptr->screen_gamma); in png_init_read_transformations()
1297 png_ptr->screen_gamma = png_ptr->gamma = PNG_FP_1; in png_init_read_transformations()
1308 png_ptr->transformations |= PNG_GAMMA; in png_init_read_transformations()
1311 png_ptr->transformations &= ~PNG_GAMMA; in png_init_read_transformations()
1345 if ((png_ptr->transformations & PNG_STRIP_ALPHA) && in png_init_read_transformations()
1346 !(png_ptr->transformations & PNG_COMPOSE)) in png_init_read_transformations()
1353 png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA | in png_init_read_transformations()
1355 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_init_read_transformations()
1364 png_ptr->num_trans = 0; in png_init_read_transformations()
1372 if (!png_gamma_significant(png_ptr->screen_gamma)) in png_init_read_transformations()
1374 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_init_read_transformations()
1375 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_init_read_transformations()
1397 if (png_ptr->transformations & PNG_BACKGROUND_EXPAND) in png_init_read_transformations()
1402 if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) in png_init_read_transformations()
1403 png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; in png_init_read_transformations()
1406 else if (png_ptr->transformations & PNG_COMPOSE) in png_init_read_transformations()
1413 if (png_ptr->transformations & PNG_GRAY_TO_RGB) in png_init_read_transformations()
1415 if (png_ptr->background.red == png_ptr->background.green && in png_init_read_transformations()
1416 png_ptr->background.red == png_ptr->background.blue) in png_init_read_transformations()
1418 png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; in png_init_read_transformations()
1419 png_ptr->background.gray = png_ptr->background.red; in png_init_read_transformations()
1436 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_init_read_transformations()
1437 png_init_palette_transformations(png_ptr); in png_init_read_transformations()
1440 png_init_rgb_transformations(png_ptr); in png_init_read_transformations()
1444 if ((png_ptr->transformations & PNG_EXPAND_16) && in png_init_read_transformations()
1445 (png_ptr->transformations & PNG_COMPOSE) && in png_init_read_transformations()
1446 !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && in png_init_read_transformations()
1447 png_ptr->bit_depth != 16) in png_init_read_transformations()
1460 CHOP(png_ptr->background.red); in png_init_read_transformations()
1461 CHOP(png_ptr->background.green); in png_init_read_transformations()
1462 CHOP(png_ptr->background.blue); in png_init_read_transformations()
1463 CHOP(png_ptr->background.gray); in png_init_read_transformations()
1471 if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) && in png_init_read_transformations()
1472 (png_ptr->transformations & PNG_COMPOSE) && in png_init_read_transformations()
1473 !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && in png_init_read_transformations()
1474 png_ptr->bit_depth == 16) in png_init_read_transformations()
1482 png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257); in png_init_read_transformations()
1483 png_ptr->background.green = in png_init_read_transformations()
1484 (png_uint_16)(png_ptr->background.green * 257); in png_init_read_transformations()
1485 png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257); in png_init_read_transformations()
1486 png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257); in png_init_read_transformations()
1501 png_ptr->background_1 = png_ptr->background; in png_init_read_transformations()
1517 if ((png_ptr->transformations & PNG_GAMMA) in png_init_read_transformations()
1518 || ((png_ptr->transformations & PNG_RGB_TO_GRAY) in png_init_read_transformations()
1519 && (png_gamma_significant(png_ptr->gamma) || in png_init_read_transformations()
1520 png_gamma_significant(png_ptr->screen_gamma))) in png_init_read_transformations()
1521 || ((png_ptr->transformations & PNG_COMPOSE) in png_init_read_transformations()
1522 && (png_gamma_significant(png_ptr->gamma) in png_init_read_transformations()
1523 || png_gamma_significant(png_ptr->screen_gamma) in png_init_read_transformations()
1525 || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE in png_init_read_transformations()
1526 && png_gamma_significant(png_ptr->background_gamma)) in png_init_read_transformations()
1528 )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) in png_init_read_transformations()
1529 && png_gamma_significant(png_ptr->screen_gamma)) in png_init_read_transformations()
1532 png_build_gamma_table(png_ptr, png_ptr->bit_depth); in png_init_read_transformations()
1535 if (png_ptr->transformations & PNG_COMPOSE) in png_init_read_transformations()
1543 if (png_ptr->transformations & PNG_RGB_TO_GRAY) in png_init_read_transformations()
1544 png_warning(png_ptr, in png_init_read_transformations()
1547 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_init_read_transformations()
1553 png_colorp palette = png_ptr->palette; in png_init_read_transformations()
1554 int num_palette = png_ptr->num_palette; in png_init_read_transformations()
1556 if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) in png_init_read_transformations()
1559 back.red = png_ptr->gamma_table[png_ptr->background.red]; in png_init_read_transformations()
1560 back.green = png_ptr->gamma_table[png_ptr->background.green]; in png_init_read_transformations()
1561 back.blue = png_ptr->gamma_table[png_ptr->background.blue]; in png_init_read_transformations()
1563 back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; in png_init_read_transformations()
1564 back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; in png_init_read_transformations()
1565 back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; in png_init_read_transformations()
1571 switch (png_ptr->background_gamma_type) in png_init_read_transformations()
1574 g = (png_ptr->screen_gamma); in png_init_read_transformations()
1579 g = png_reciprocal(png_ptr->gamma); in png_init_read_transformations()
1580 gs = png_reciprocal2(png_ptr->gamma, in png_init_read_transformations()
1581 png_ptr->screen_gamma); in png_init_read_transformations()
1585 g = png_reciprocal(png_ptr->background_gamma); in png_init_read_transformations()
1586 gs = png_reciprocal2(png_ptr->background_gamma, in png_init_read_transformations()
1587 png_ptr->screen_gamma); in png_init_read_transformations()
1597 back.red = png_gamma_8bit_correct(png_ptr->background.red, in png_init_read_transformations()
1599 back.green = png_gamma_8bit_correct(png_ptr->background.green, in png_init_read_transformations()
1601 back.blue = png_gamma_8bit_correct(png_ptr->background.blue, in png_init_read_transformations()
1607 back.red = (png_byte)png_ptr->background.red; in png_init_read_transformations()
1608 back.green = (png_byte)png_ptr->background.green; in png_init_read_transformations()
1609 back.blue = (png_byte)png_ptr->background.blue; in png_init_read_transformations()
1614 back_1.red = png_gamma_8bit_correct(png_ptr->background.red, in png_init_read_transformations()
1617 png_ptr->background.green, g); in png_init_read_transformations()
1618 back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue, in png_init_read_transformations()
1624 back_1.red = (png_byte)png_ptr->background.red; in png_init_read_transformations()
1625 back_1.green = (png_byte)png_ptr->background.green; in png_init_read_transformations()
1626 back_1.blue = (png_byte)png_ptr->background.blue; in png_init_read_transformations()
1632 if (i < (int)png_ptr->num_trans && in png_init_read_transformations()
1633 png_ptr->trans_alpha[i] != 0xff) in png_init_read_transformations()
1635 if (png_ptr->trans_alpha[i] == 0) in png_init_read_transformations()
1643 v = png_ptr->gamma_to_1[palette[i].red]; in png_init_read_transformations()
1644 png_composite(w, v, png_ptr->trans_alpha[i], back_1.red); in png_init_read_transformations()
1645 palette[i].red = png_ptr->gamma_from_1[w]; in png_init_read_transformations()
1647 v = png_ptr->gamma_to_1[palette[i].green]; in png_init_read_transformations()
1648 png_composite(w, v, png_ptr->trans_alpha[i], back_1.green); in png_init_read_transformations()
1649 palette[i].green = png_ptr->gamma_from_1[w]; in png_init_read_transformations()
1651 v = png_ptr->gamma_to_1[palette[i].blue]; in png_init_read_transformations()
1652 png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue); in png_init_read_transformations()
1653 palette[i].blue = png_ptr->gamma_from_1[w]; in png_init_read_transformations()
1658 palette[i].red = png_ptr->gamma_table[palette[i].red]; in png_init_read_transformations()
1659 palette[i].green = png_ptr->gamma_table[palette[i].green]; in png_init_read_transformations()
1660 palette[i].blue = png_ptr->gamma_table[palette[i].blue]; in png_init_read_transformations()
1670 png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA); in png_init_read_transformations()
1680 switch (png_ptr->background_gamma_type) in png_init_read_transformations()
1683 g = png_ptr->screen_gamma; in png_init_read_transformations()
1688 g = png_reciprocal(png_ptr->gamma); in png_init_read_transformations()
1689 gs = png_reciprocal2(png_ptr->gamma, png_ptr->screen_gamma); in png_init_read_transformations()
1693 g = png_reciprocal(png_ptr->background_gamma); in png_init_read_transformations()
1694 gs = png_reciprocal2(png_ptr->background_gamma, in png_init_read_transformations()
1695 png_ptr->screen_gamma); in png_init_read_transformations()
1699 png_error(png_ptr, "invalid background gamma type"); in png_init_read_transformations()
1706 png_ptr->background_1.gray = png_gamma_correct(png_ptr, in png_init_read_transformations()
1707 png_ptr->background.gray, g); in png_init_read_transformations()
1710 png_ptr->background.gray = png_gamma_correct(png_ptr, in png_init_read_transformations()
1711 png_ptr->background.gray, gs); in png_init_read_transformations()
1713 if ((png_ptr->background.red != png_ptr->background.green) || in png_init_read_transformations()
1714 (png_ptr->background.red != png_ptr->background.blue) || in png_init_read_transformations()
1715 (png_ptr->background.red != png_ptr->background.gray)) in png_init_read_transformations()
1720 png_ptr->background_1.red = png_gamma_correct(png_ptr, in png_init_read_transformations()
1721 png_ptr->background.red, g); in png_init_read_transformations()
1723 png_ptr->background_1.green = png_gamma_correct(png_ptr, in png_init_read_transformations()
1724 png_ptr->background.green, g); in png_init_read_transformations()
1726 png_ptr->background_1.blue = png_gamma_correct(png_ptr, in png_init_read_transformations()
1727 png_ptr->background.blue, g); in png_init_read_transformations()
1732 png_ptr->background.red = png_gamma_correct(png_ptr, in png_init_read_transformations()
1733 png_ptr->background.red, gs); in png_init_read_transformations()
1735 png_ptr->background.green = png_gamma_correct(png_ptr, in png_init_read_transformations()
1736 png_ptr->background.green, gs); in png_init_read_transformations()
1738 png_ptr->background.blue = png_gamma_correct(png_ptr, in png_init_read_transformations()
1739 png_ptr->background.blue, gs); in png_init_read_transformations()
1746 png_ptr->background_1.red = png_ptr->background_1.green in png_init_read_transformations()
1747 = png_ptr->background_1.blue = png_ptr->background_1.gray; in png_init_read_transformations()
1749 png_ptr->background.red = png_ptr->background.green in png_init_read_transformations()
1750 = png_ptr->background.blue = png_ptr->background.gray; in png_init_read_transformations()
1754 png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN; in png_init_read_transformations()
1761 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE in png_init_read_transformations()
1764 && ((png_ptr->transformations & PNG_EXPAND) == 0 || in png_init_read_transformations()
1765 (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) in png_init_read_transformations()
1769 png_colorp palette = png_ptr->palette; in png_init_read_transformations()
1770 int num_palette = png_ptr->num_palette; in png_init_read_transformations()
1778 palette[i].red = png_ptr->gamma_table[palette[i].red]; in png_init_read_transformations()
1779 palette[i].green = png_ptr->gamma_table[palette[i].green]; in png_init_read_transformations()
1780 palette[i].blue = png_ptr->gamma_table[palette[i].blue]; in png_init_read_transformations()
1784 png_ptr->transformations &= ~PNG_GAMMA; in png_init_read_transformations()
1794 if ((png_ptr->transformations & PNG_COMPOSE) && in png_init_read_transformations()
1795 (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) in png_init_read_transformations()
1798 int istop = (int)png_ptr->num_trans; in png_init_read_transformations()
1800 png_colorp palette = png_ptr->palette; in png_init_read_transformations()
1802 back.red = (png_byte)png_ptr->background.red; in png_init_read_transformations()
1803 back.green = (png_byte)png_ptr->background.green; in png_init_read_transformations()
1804 back.blue = (png_byte)png_ptr->background.blue; in png_init_read_transformations()
1808 if (png_ptr->trans_alpha[i] == 0) in png_init_read_transformations()
1813 else if (png_ptr->trans_alpha[i] != 0xff) in png_init_read_transformations()
1817 png_ptr->trans_alpha[i], back.red); in png_init_read_transformations()
1820 png_ptr->trans_alpha[i], back.green); in png_init_read_transformations()
1823 png_ptr->trans_alpha[i], back.blue); in png_init_read_transformations()
1827 png_ptr->transformations &= ~PNG_COMPOSE; in png_init_read_transformations()
1832 if ((png_ptr->transformations & PNG_SHIFT) && in png_init_read_transformations()
1833 !(png_ptr->transformations & PNG_EXPAND) && in png_init_read_transformations()
1834 (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) in png_init_read_transformations()
1837 int istop = png_ptr->num_palette; in png_init_read_transformations()
1838 int shift = 8 - png_ptr->sig_bit.red; in png_init_read_transformations()
1840 png_ptr->transformations &= ~PNG_SHIFT; in png_init_read_transformations()
1848 int component = png_ptr->palette[i].red; in png_init_read_transformations()
1851 png_ptr->palette[i].red = (png_byte)component; in png_init_read_transformations()
1854 shift = 8 - png_ptr->sig_bit.green; in png_init_read_transformations()
1857 int component = png_ptr->palette[i].green; in png_init_read_transformations()
1860 png_ptr->palette[i].green = (png_byte)component; in png_init_read_transformations()
1863 shift = 8 - png_ptr->sig_bit.blue; in png_init_read_transformations()
1866 int component = png_ptr->palette[i].blue; in png_init_read_transformations()
1869 png_ptr->palette[i].blue = (png_byte)component; in png_init_read_transformations()
1880 png_read_transform_info(png_structp png_ptr, png_infop info_ptr) in png_read_transform_info() argument
1885 if (png_ptr->transformations & PNG_EXPAND) in png_read_transform_info()
1893 if (png_ptr->num_trans > 0) in png_read_transform_info()
1904 if (png_ptr->num_trans) in png_read_transform_info()
1906 if (png_ptr->transformations & PNG_EXPAND_tRNS) in png_read_transform_info()
1922 if (png_ptr->transformations & PNG_COMPOSE) in png_read_transform_info()
1923 info_ptr->background = png_ptr->background; in png_read_transform_info()
1932 info_ptr->gamma = png_ptr->gamma; in png_read_transform_info()
1939 if (png_ptr->transformations & PNG_SCALE_16_TO_8) in png_read_transform_info()
1944 if (png_ptr->transformations & PNG_16_TO_8) in png_read_transform_info()
1958 png_ptr->transformations |= PNG_16_TO_8; in png_read_transform_info()
1963 png_ptr->transformations |= PNG_SCALE_16_TO_8; in png_read_transform_info()
1974 if (png_ptr->transformations & PNG_GRAY_TO_RGB) in png_read_transform_info()
1980 if (png_ptr->transformations & PNG_RGB_TO_GRAY) in png_read_transform_info()
1986 if (png_ptr->transformations & PNG_QUANTIZE) in png_read_transform_info()
1990 png_ptr->palette_lookup && info_ptr->bit_depth == 8) in png_read_transform_info()
1998 if (png_ptr->transformations & PNG_EXPAND_16 && info_ptr->bit_depth == 8 && in png_read_transform_info()
2006 if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) in png_read_transform_info()
2020 if (png_ptr->transformations & PNG_STRIP_ALPHA) in png_read_transform_info()
2033 if ((png_ptr->transformations & PNG_FILLER) && in png_read_transform_info()
2039 if (png_ptr->transformations & PNG_ADD_ALPHA) in png_read_transform_info()
2046 if (png_ptr->transformations & PNG_USER_TRANSFORM) in png_read_transform_info()
2048 if (info_ptr->bit_depth < png_ptr->user_transform_depth) in png_read_transform_info()
2049 info_ptr->bit_depth = png_ptr->user_transform_depth; in png_read_transform_info()
2051 if (info_ptr->channels < png_ptr->user_transform_channels) in png_read_transform_info()
2052 info_ptr->channels = png_ptr->user_transform_channels; in png_read_transform_info()
2067 png_ptr->info_rowbytes = info_ptr->rowbytes; in png_read_transform_info()
2070 if (png_ptr) in png_read_transform_info()
2080 png_do_read_transformations(png_structp png_ptr, png_row_infop row_info) in png_do_read_transformations() argument
2084 if (png_ptr->row_buf == NULL) in png_do_read_transformations()
2090 png_error(png_ptr, "NULL row buffer"); in png_do_read_transformations()
2098 if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 && in png_do_read_transformations()
2099 !(png_ptr->flags & PNG_FLAG_ROW_INIT)) in png_do_read_transformations()
2105 png_error(png_ptr, "Uninitialized row"); in png_do_read_transformations()
2109 if (png_ptr->transformations & PNG_EXPAND) in png_do_read_transformations()
2113 png_do_expand_palette(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
2114 png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans); in png_do_read_transformations()
2119 if (png_ptr->num_trans && in png_do_read_transformations()
2120 (png_ptr->transformations & PNG_EXPAND_tRNS)) in png_do_read_transformations()
2121 png_do_expand(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
2122 &(png_ptr->trans_color)); in png_do_read_transformations()
2125 png_do_expand(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
2132 if ((png_ptr->transformations & PNG_STRIP_ALPHA) && in png_do_read_transformations()
2133 !(png_ptr->transformations & PNG_COMPOSE) && in png_do_read_transformations()
2136 png_do_strip_channel(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
2141 if (png_ptr->transformations & PNG_RGB_TO_GRAY) in png_do_read_transformations()
2144 png_do_rgb_to_gray(png_ptr, row_info, in png_do_read_transformations()
2145 png_ptr->row_buf + 1); in png_do_read_transformations()
2149 png_ptr->rgb_to_gray_status=1; in png_do_read_transformations()
2150 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == in png_do_read_transformations()
2152 png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); in png_do_read_transformations()
2154 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == in png_do_read_transformations()
2156 png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); in png_do_read_transformations()
2196 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && in png_do_read_transformations()
2197 !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) in png_do_read_transformations()
2198 png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2203 if (png_ptr->transformations & PNG_COMPOSE) in png_do_read_transformations()
2204 png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr); in png_do_read_transformations()
2208 if ((png_ptr->transformations & PNG_GAMMA) && in png_do_read_transformations()
2211 !(png_ptr->transformations & PNG_RGB_TO_GRAY) && in png_do_read_transformations()
2218 !((png_ptr->transformations & PNG_COMPOSE) && in png_do_read_transformations()
2219 ((png_ptr->num_trans != 0) || in png_do_read_transformations()
2220 (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && in png_do_read_transformations()
2225 (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) in png_do_read_transformations()
2226 png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr); in png_do_read_transformations()
2230 if ((png_ptr->transformations & PNG_STRIP_ALPHA) && in png_do_read_transformations()
2231 (png_ptr->transformations & PNG_COMPOSE) && in png_do_read_transformations()
2234 png_do_strip_channel(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
2239 if ((png_ptr->transformations & PNG_ENCODE_ALPHA) && in png_do_read_transformations()
2241 png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr); in png_do_read_transformations()
2245 if (png_ptr->transformations & PNG_SCALE_16_TO_8) in png_do_read_transformations()
2246 png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2254 if (png_ptr->transformations & PNG_16_TO_8) in png_do_read_transformations()
2255 png_do_chop(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2259 if (png_ptr->transformations & PNG_QUANTIZE) in png_do_read_transformations()
2261 png_do_quantize(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
2262 png_ptr->palette_lookup, png_ptr->quantize_index); in png_do_read_transformations()
2265 png_error(png_ptr, "png_do_quantize returned rowbytes=0"); in png_do_read_transformations()
2275 if (png_ptr->transformations & PNG_EXPAND_16) in png_do_read_transformations()
2276 png_do_expand_16(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2281 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && in png_do_read_transformations()
2282 (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) in png_do_read_transformations()
2283 png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2287 if (png_ptr->transformations & PNG_INVERT_MONO) in png_do_read_transformations()
2288 png_do_invert(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2292 if (png_ptr->transformations & PNG_SHIFT) in png_do_read_transformations()
2293 png_do_unshift(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
2294 &(png_ptr->shift)); in png_do_read_transformations()
2298 if (png_ptr->transformations & PNG_PACK) in png_do_read_transformations()
2299 png_do_unpack(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2305 png_ptr->num_palette_max >= 0) in png_do_read_transformations()
2306 png_do_check_palette_indexes(png_ptr, row_info); in png_do_read_transformations()
2310 if (png_ptr->transformations & PNG_BGR) in png_do_read_transformations()
2311 png_do_bgr(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2315 if (png_ptr->transformations & PNG_PACKSWAP) in png_do_read_transformations()
2316 png_do_packswap(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2320 if (png_ptr->transformations & PNG_FILLER) in png_do_read_transformations()
2321 png_do_read_filler(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
2322 (png_uint_32)png_ptr->filler, png_ptr->flags); in png_do_read_transformations()
2326 if (png_ptr->transformations & PNG_INVERT_ALPHA) in png_do_read_transformations()
2327 png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2331 if (png_ptr->transformations & PNG_SWAP_ALPHA) in png_do_read_transformations()
2332 png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2337 if (png_ptr->transformations & PNG_SWAP_BYTES) in png_do_read_transformations()
2338 png_do_swap(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
2343 if (png_ptr->transformations & PNG_USER_TRANSFORM) in png_do_read_transformations()
2345 if (png_ptr->read_user_transform_fn != NULL) in png_do_read_transformations()
2346 (*(png_ptr->read_user_transform_fn)) /* User read transform function */ in png_do_read_transformations()
2347 (png_ptr, /* png_ptr */ in png_do_read_transformations()
2355 png_ptr->row_buf + 1); /* start of pixel data for row */ in png_do_read_transformations()
2357 if (png_ptr->user_transform_depth) in png_do_read_transformations()
2358 row_info->bit_depth = png_ptr->user_transform_depth; in png_do_read_transformations()
2360 if (png_ptr->user_transform_channels) in png_do_read_transformations()
2361 row_info->channels = png_ptr->user_transform_channels; in png_do_read_transformations()
3227 png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) in png_do_rgb_to_gray() argument
3237 PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; in png_do_rgb_to_gray()
3238 PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; in png_do_rgb_to_gray()
3252 if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) in png_do_rgb_to_gray()
3266 red = png_ptr->gamma_to_1[red]; in png_do_rgb_to_gray()
3267 green = png_ptr->gamma_to_1[green]; in png_do_rgb_to_gray()
3268 blue = png_ptr->gamma_to_1[blue]; in png_do_rgb_to_gray()
3271 *(dp++) = png_ptr->gamma_from_1[ in png_do_rgb_to_gray()
3280 if (png_ptr->gamma_table != NULL) in png_do_rgb_to_gray()
3281 red = png_ptr->gamma_table[red]; in png_do_rgb_to_gray()
3324 if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL) in png_do_rgb_to_gray()
3340 if (png_ptr->gamma_16_table != NULL) in png_do_rgb_to_gray()
3341 w = png_ptr->gamma_16_table[(red&0xff) in png_do_rgb_to_gray()
3342 >> png_ptr->gamma_shift][red>>8]; in png_do_rgb_to_gray()
3350 png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) in png_do_rgb_to_gray()
3351 >> png_ptr->gamma_shift][red>>8]; in png_do_rgb_to_gray()
3353 png_ptr->gamma_16_to_1[(green&0xff) >> in png_do_rgb_to_gray()
3354 png_ptr->gamma_shift][green>>8]; in png_do_rgb_to_gray()
3355 png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) in png_do_rgb_to_gray()
3356 >> png_ptr->gamma_shift][blue>>8]; in png_do_rgb_to_gray()
3359 w = png_ptr->gamma_16_from_1[(gray16&0xff) >> in png_do_rgb_to_gray()
3360 png_ptr->gamma_shift][gray16 >> 8]; in png_do_rgb_to_gray()
3487 png_do_compose(png_row_infop row_info, png_bytep row, png_structp png_ptr) in png_do_compose() argument
3490 png_const_bytep gamma_table = png_ptr->gamma_table; in png_do_compose()
3491 png_const_bytep gamma_from_1 = png_ptr->gamma_from_1; in png_do_compose()
3492 png_const_bytep gamma_to_1 = png_ptr->gamma_to_1; in png_do_compose()
3493 png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table; in png_do_compose()
3494 png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1; in png_do_compose()
3495 png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1; in png_do_compose()
3496 int gamma_shift = png_ptr->gamma_shift; in png_do_compose()
3502 int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0; in png_do_compose()
3521 == png_ptr->trans_color.gray) in png_do_compose()
3524 *sp |= (png_byte)(png_ptr->background.gray << shift); in png_do_compose()
3549 == png_ptr->trans_color.gray) in png_do_compose()
3552 *sp |= (png_byte)(png_ptr->background.gray << shift); in png_do_compose()
3583 == png_ptr->trans_color.gray) in png_do_compose()
3586 *sp |= (png_byte)(png_ptr->background.gray << shift); in png_do_compose()
3612 == png_ptr->trans_color.gray) in png_do_compose()
3615 *sp |= (png_byte)(png_ptr->background.gray << shift); in png_do_compose()
3646 == png_ptr->trans_color.gray) in png_do_compose()
3649 *sp |= (png_byte)(png_ptr->background.gray << shift); in png_do_compose()
3673 if (*sp == png_ptr->trans_color.gray) in png_do_compose()
3674 *sp = (png_byte)png_ptr->background.gray; in png_do_compose()
3686 if (*sp == png_ptr->trans_color.gray) in png_do_compose()
3687 *sp = (png_byte)png_ptr->background.gray; in png_do_compose()
3705 if (v == png_ptr->trans_color.gray) in png_do_compose()
3708 *sp = (png_byte)((png_ptr->background.gray >> 8) in png_do_compose()
3710 *(sp + 1) = (png_byte)(png_ptr->background.gray in png_do_compose()
3732 if (v == png_ptr->trans_color.gray) in png_do_compose()
3734 *sp = (png_byte)((png_ptr->background.gray >> 8) in png_do_compose()
3736 *(sp + 1) = (png_byte)(png_ptr->background.gray in png_do_compose()
3760 if (*sp == png_ptr->trans_color.red && in png_do_compose()
3761 *(sp + 1) == png_ptr->trans_color.green && in png_do_compose()
3762 *(sp + 2) == png_ptr->trans_color.blue) in png_do_compose()
3764 *sp = (png_byte)png_ptr->background.red; in png_do_compose()
3765 *(sp + 1) = (png_byte)png_ptr->background.green; in png_do_compose()
3766 *(sp + 2) = (png_byte)png_ptr->background.blue; in png_do_compose()
3783 if (*sp == png_ptr->trans_color.red && in png_do_compose()
3784 *(sp + 1) == png_ptr->trans_color.green && in png_do_compose()
3785 *(sp + 2) == png_ptr->trans_color.blue) in png_do_compose()
3787 *sp = (png_byte)png_ptr->background.red; in png_do_compose()
3788 *(sp + 1) = (png_byte)png_ptr->background.green; in png_do_compose()
3789 *(sp + 2) = (png_byte)png_ptr->background.blue; in png_do_compose()
3810 if (r == png_ptr->trans_color.red && in png_do_compose()
3811 g == png_ptr->trans_color.green && in png_do_compose()
3812 b == png_ptr->trans_color.blue) in png_do_compose()
3815 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); in png_do_compose()
3816 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); in png_do_compose()
3817 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) in png_do_compose()
3819 *(sp + 3) = (png_byte)(png_ptr->background.green in png_do_compose()
3821 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) in png_do_compose()
3823 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); in png_do_compose()
3857 if (r == png_ptr->trans_color.red && in png_do_compose()
3858 g == png_ptr->trans_color.green && in png_do_compose()
3859 b == png_ptr->trans_color.blue) in png_do_compose()
3861 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); in png_do_compose()
3862 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); in png_do_compose()
3863 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) in png_do_compose()
3865 *(sp + 3) = (png_byte)(png_ptr->background.green in png_do_compose()
3867 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) in png_do_compose()
3869 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); in png_do_compose()
3896 *sp = (png_byte)png_ptr->background.gray; in png_do_compose()
3904 png_composite(w, v, a, png_ptr->background_1.gray); in png_do_compose()
3920 *sp = (png_byte)png_ptr->background.gray; in png_do_compose()
3923 png_composite(*sp, *sp, a, png_ptr->background_1.gray); in png_do_compose()
3951 *sp = (png_byte)((png_ptr->background.gray >> 8) in png_do_compose()
3953 *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); in png_do_compose()
3961 png_composite_16(v, g, a, png_ptr->background_1.gray); in png_do_compose()
3982 *sp = (png_byte)((png_ptr->background.gray >> 8) in png_do_compose()
3984 *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); in png_do_compose()
3992 png_composite_16(v, g, a, png_ptr->background_1.gray); in png_do_compose()
4025 *sp = (png_byte)png_ptr->background.red; in png_do_compose()
4026 *(sp + 1) = (png_byte)png_ptr->background.green; in png_do_compose()
4027 *(sp + 2) = (png_byte)png_ptr->background.blue; in png_do_compose()
4035 png_composite(w, v, a, png_ptr->background_1.red); in png_do_compose()
4040 png_composite(w, v, a, png_ptr->background_1.green); in png_do_compose()
4045 png_composite(w, v, a, png_ptr->background_1.blue); in png_do_compose()
4061 *sp = (png_byte)png_ptr->background.red; in png_do_compose()
4062 *(sp + 1) = (png_byte)png_ptr->background.green; in png_do_compose()
4063 *(sp + 2) = (png_byte)png_ptr->background.blue; in png_do_compose()
4068 png_composite(*sp, *sp, a, png_ptr->background.red); in png_do_compose()
4071 png_ptr->background.green); in png_do_compose()
4074 png_ptr->background.blue); in png_do_compose()
4111 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); in png_do_compose()
4112 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); in png_do_compose()
4113 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) in png_do_compose()
4115 *(sp + 3) = (png_byte)(png_ptr->background.green in png_do_compose()
4117 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) in png_do_compose()
4119 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); in png_do_compose()
4127 png_composite_16(w, v, a, png_ptr->background_1.red); in png_do_compose()
4135 png_composite_16(w, v, a, png_ptr->background_1.green); in png_do_compose()
4144 png_composite_16(w, v, a, png_ptr->background_1.blue); in png_do_compose()
4166 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); in png_do_compose()
4167 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); in png_do_compose()
4168 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) in png_do_compose()
4170 *(sp + 3) = (png_byte)(png_ptr->background.green in png_do_compose()
4172 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) in png_do_compose()
4174 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); in png_do_compose()
4187 png_composite_16(v, r, a, png_ptr->background.red); in png_do_compose()
4191 png_composite_16(v, g, a, png_ptr->background.green); in png_do_compose()
4195 png_composite_16(v, b, a, png_ptr->background.blue); in png_do_compose()
4220 png_do_gamma(png_row_infop row_info, png_bytep row, png_structp png_ptr) in png_do_gamma() argument
4222 png_const_bytep gamma_table = png_ptr->gamma_table; in png_do_gamma()
4223 png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table; in png_do_gamma()
4224 int gamma_shift = png_ptr->gamma_shift; in png_do_gamma()
4421 png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structp png_ptr) in png_do_encode_alpha() argument
4431 PNG_CONST png_bytep table = png_ptr->gamma_from_1; in png_do_encode_alpha()
4450 PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1; in png_do_encode_alpha()
4451 PNG_CONST int gamma_shift = png_ptr->gamma_shift; in png_do_encode_alpha()
4478 png_warning(png_ptr, "png_do_encode_alpha: unexpected call"); in png_do_encode_alpha()