• Home
  • Raw
  • Download

Lines Matching refs:png_ptr

36 png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)  in png_set_crc_action()  argument
40 if (png_ptr == NULL) in png_set_crc_action()
50 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; in png_set_crc_action()
51 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; in png_set_crc_action()
55 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; in png_set_crc_action()
56 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | in png_set_crc_action()
61 png_warning(png_ptr, in png_set_crc_action()
68 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; in png_set_crc_action()
79 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
80 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; in png_set_crc_action()
84 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
85 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | in png_set_crc_action()
90 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
91 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; in png_set_crc_action()
98 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
110 png_rtran_ok(png_structrp png_ptr, int need_IHDR) in png_rtran_ok() argument
112 if (png_ptr != NULL) in png_rtran_ok()
114 if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) in png_rtran_ok()
115 png_app_error(png_ptr, in png_rtran_ok()
118 else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0) in png_rtran_ok()
119 png_app_error(png_ptr, "invalid before the PNG header has been read"); in png_rtran_ok()
124 png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED; in png_rtran_ok()
137 png_set_background_fixed(png_structrp png_ptr, in png_set_background_fixed() argument
143 if (png_rtran_ok(png_ptr, 0) == 0 || background_color == NULL) in png_set_background_fixed()
148 png_warning(png_ptr, "Application must supply a known background gamma"); in png_set_background_fixed()
152 png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA; in png_set_background_fixed()
153 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_set_background_fixed()
154 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_set_background_fixed()
156 png_ptr->background = *background_color; in png_set_background_fixed()
157 png_ptr->background_gamma = background_gamma; in png_set_background_fixed()
158 png_ptr->background_gamma_type = (png_byte)(background_gamma_code); in png_set_background_fixed()
160 png_ptr->transformations |= PNG_BACKGROUND_EXPAND; in png_set_background_fixed()
162 png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; in png_set_background_fixed()
167 png_set_background(png_structrp png_ptr, in png_set_background() argument
171 png_set_background_fixed(png_ptr, background_color, background_gamma_code, in png_set_background()
172 need_expand, png_fixed(png_ptr, background_gamma, "png_set_background")); in png_set_background()
183 png_set_scale_16(png_structrp png_ptr) in png_set_scale_16() argument
187 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_scale_16()
190 png_ptr->transformations |= PNG_SCALE_16_TO_8; in png_set_scale_16()
197 png_set_strip_16(png_structrp png_ptr) in png_set_strip_16() argument
201 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_strip_16()
204 png_ptr->transformations |= PNG_16_TO_8; in png_set_strip_16()
210 png_set_strip_alpha(png_structrp png_ptr) in png_set_strip_alpha() argument
214 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_strip_alpha()
217 png_ptr->transformations |= PNG_STRIP_ALPHA; in png_set_strip_alpha()
223 translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, in translate_gamma_flags() argument
238 png_ptr->flags |= PNG_FLAG_ASSUME_sRGB; in translate_gamma_flags()
240 PNG_UNUSED(png_ptr) in translate_gamma_flags()
262 convert_gamma_value(png_structrp png_ptr, double output_gamma) in convert_gamma_value() argument
278 png_fixed_error(png_ptr, "gamma value"); in convert_gamma_value()
287 png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, in png_set_alpha_mode_fixed() argument
295 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_alpha_mode_fixed()
298 output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/); in png_set_alpha_mode_fixed()
310 png_error(png_ptr, "output gamma out of expected range"); in png_set_alpha_mode_fixed()
337 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_set_alpha_mode_fixed()
338 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_set_alpha_mode_fixed()
343 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_set_alpha_mode_fixed()
344 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_set_alpha_mode_fixed()
351 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_set_alpha_mode_fixed()
352 png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA; in png_set_alpha_mode_fixed()
358 png_ptr->transformations |= PNG_ENCODE_ALPHA; in png_set_alpha_mode_fixed()
359 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_set_alpha_mode_fixed()
363 png_error(png_ptr, "invalid alpha mode"); in png_set_alpha_mode_fixed()
370 if (png_ptr->colorspace.gamma == 0) in png_set_alpha_mode_fixed()
372 png_ptr->colorspace.gamma = file_gamma; in png_set_alpha_mode_fixed()
373 png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; in png_set_alpha_mode_fixed()
377 png_ptr->screen_gamma = output_gamma; in png_set_alpha_mode_fixed()
385 memset(&png_ptr->background, 0, (sizeof png_ptr->background)); in png_set_alpha_mode_fixed()
386 png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */ in png_set_alpha_mode_fixed()
387 png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE; in png_set_alpha_mode_fixed()
388 png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; in png_set_alpha_mode_fixed()
390 if ((png_ptr->transformations & PNG_COMPOSE) != 0) in png_set_alpha_mode_fixed()
391 png_error(png_ptr, in png_set_alpha_mode_fixed()
394 png_ptr->transformations |= PNG_COMPOSE; in png_set_alpha_mode_fixed()
400 png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma) in png_set_alpha_mode() argument
402 png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr, in png_set_alpha_mode()
428 png_set_quantize(png_structrp png_ptr, png_colorp palette, in png_set_quantize() argument
434 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_quantize()
437 png_ptr->transformations |= PNG_QUANTIZE; in png_set_quantize()
443 png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, in png_set_quantize()
446 png_ptr->quantize_index[i] = (png_byte)i; in png_set_quantize()
460 png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, in png_set_quantize()
465 png_ptr->quantize_sort[i] = (png_byte)i; in png_set_quantize()
482 if (histogram[png_ptr->quantize_sort[j]] in png_set_quantize()
483 < histogram[png_ptr->quantize_sort[j + 1]]) in png_set_quantize()
487 t = png_ptr->quantize_sort[j]; in png_set_quantize()
488 png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1]; in png_set_quantize()
489 png_ptr->quantize_sort[j + 1] = t; in png_set_quantize()
508 if ((int)png_ptr->quantize_sort[i] >= maximum_colors) in png_set_quantize()
512 while ((int)png_ptr->quantize_sort[j] >= maximum_colors); in png_set_quantize()
528 if ((int)png_ptr->quantize_sort[i] >= maximum_colors) in png_set_quantize()
534 while ((int)png_ptr->quantize_sort[j] >= maximum_colors); in png_set_quantize()
540 png_ptr->quantize_index[j] = (png_byte)i; in png_set_quantize()
541 png_ptr->quantize_index[i] = (png_byte)j; in png_set_quantize()
548 if ((int)png_ptr->quantize_index[i] >= maximum_colors) in png_set_quantize()
553 d_index = png_ptr->quantize_index[i]; in png_set_quantize()
568 png_ptr->quantize_index[i] = (png_byte)min_k; in png_set_quantize()
572 png_free(png_ptr, png_ptr->quantize_sort); in png_set_quantize()
573 png_ptr->quantize_sort = NULL; in png_set_quantize()
594 png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, in png_set_quantize()
597 png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, in png_set_quantize()
604 png_ptr->index_to_palette[i] = (png_byte)i; in png_set_quantize()
605 png_ptr->palette_to_index[i] = (png_byte)i; in png_set_quantize()
608 hash = (png_dsortpp)png_calloc(png_ptr, (png_alloc_size_t)(769 * in png_set_quantize()
638 t = (png_dsortp)png_malloc_warn(png_ptr, in png_set_quantize()
663 if ((int)png_ptr->index_to_palette[p->left] in png_set_quantize()
665 (int)png_ptr->index_to_palette[p->right] in png_set_quantize()
682 palette[png_ptr->index_to_palette[j]] in png_set_quantize()
690 if (png_ptr->quantize_index[k] == in png_set_quantize()
691 png_ptr->index_to_palette[j]) in png_set_quantize()
692 png_ptr->quantize_index[k] = in png_set_quantize()
693 png_ptr->index_to_palette[next_j]; in png_set_quantize()
695 if ((int)png_ptr->quantize_index[k] == in png_set_quantize()
697 png_ptr->quantize_index[k] = in png_set_quantize()
698 png_ptr->index_to_palette[j]; in png_set_quantize()
702 png_ptr->index_to_palette[png_ptr->palette_to_index in png_set_quantize()
703 [num_new_palette]] = png_ptr->index_to_palette[j]; in png_set_quantize()
705 png_ptr->palette_to_index[png_ptr->index_to_palette[j]] in png_set_quantize()
706 = png_ptr->palette_to_index[num_new_palette]; in png_set_quantize()
708 png_ptr->index_to_palette[j] = in png_set_quantize()
711 png_ptr->palette_to_index[num_new_palette] = in png_set_quantize()
730 png_free(png_ptr, p); in png_set_quantize()
738 png_free(png_ptr, hash); in png_set_quantize()
739 png_free(png_ptr, png_ptr->palette_to_index); in png_set_quantize()
740 png_free(png_ptr, png_ptr->index_to_palette); in png_set_quantize()
741 png_ptr->palette_to_index = NULL; in png_set_quantize()
742 png_ptr->index_to_palette = NULL; in png_set_quantize()
746 if (png_ptr->palette == NULL) in png_set_quantize()
748 png_ptr->palette = palette; in png_set_quantize()
750 png_ptr->num_palette = (png_uint_16)num_palette; in png_set_quantize()
763 png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr, in png_set_quantize()
766 distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries * in png_set_quantize()
804 png_ptr->palette_lookup[d_index] = (png_byte)i; in png_set_quantize()
811 png_free(png_ptr, distance); in png_set_quantize()
818 png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, in png_set_gamma_fixed() argument
823 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_gamma_fixed()
827 scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/); in png_set_gamma_fixed()
828 file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/); in png_set_gamma_fixed()
842 png_error(png_ptr, "invalid file gamma in png_set_gamma"); in png_set_gamma_fixed()
845 png_error(png_ptr, "invalid screen gamma in png_set_gamma"); in png_set_gamma_fixed()
851 png_ptr->colorspace.gamma = file_gamma; in png_set_gamma_fixed()
852 png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; in png_set_gamma_fixed()
853 png_ptr->screen_gamma = scrn_gamma; in png_set_gamma_fixed()
858 png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma) in png_set_gamma() argument
860 png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma), in png_set_gamma()
861 convert_gamma_value(png_ptr, file_gamma)); in png_set_gamma()
872 png_set_expand(png_structrp png_ptr) in png_set_expand() argument
876 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_expand()
879 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_expand()
902 png_set_palette_to_rgb(png_structrp png_ptr) in png_set_palette_to_rgb() argument
906 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_palette_to_rgb()
909 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_palette_to_rgb()
914 png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr) in png_set_expand_gray_1_2_4_to_8() argument
918 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_expand_gray_1_2_4_to_8()
921 png_ptr->transformations |= PNG_EXPAND; in png_set_expand_gray_1_2_4_to_8()
926 png_set_tRNS_to_alpha(png_structrp png_ptr) in png_set_tRNS_to_alpha() argument
930 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_tRNS_to_alpha()
933 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_tRNS_to_alpha()
942 png_set_expand_16(png_structrp png_ptr) in png_set_expand_16() argument
946 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_expand_16()
949 png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_expand_16()
955 png_set_gray_to_rgb(png_structrp png_ptr) in png_set_gray_to_rgb() argument
959 if (png_rtran_ok(png_ptr, 0) == 0) in png_set_gray_to_rgb()
963 png_set_expand_gray_1_2_4_to_8(png_ptr); in png_set_gray_to_rgb()
964 png_ptr->transformations |= PNG_GRAY_TO_RGB; in png_set_gray_to_rgb()
970 png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, in png_set_rgb_to_gray_fixed() argument
977 if (png_rtran_ok(png_ptr, 1) == 0) in png_set_rgb_to_gray_fixed()
983 png_ptr->transformations |= PNG_RGB_TO_GRAY; in png_set_rgb_to_gray_fixed()
987 png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; in png_set_rgb_to_gray_fixed()
991 png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; in png_set_rgb_to_gray_fixed()
995 png_error(png_ptr, "invalid error action to rgb_to_gray"); in png_set_rgb_to_gray_fixed()
998 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_set_rgb_to_gray_fixed()
1000 png_ptr->transformations |= PNG_EXPAND; in png_set_rgb_to_gray_fixed()
1006 png_error(png_ptr, in png_set_rgb_to_gray_fixed()
1025 png_ptr->rgb_to_gray_red_coeff = red_int; in png_set_rgb_to_gray_fixed()
1026 png_ptr->rgb_to_gray_green_coeff = green_int; in png_set_rgb_to_gray_fixed()
1027 png_ptr->rgb_to_gray_coefficients_set = 1; in png_set_rgb_to_gray_fixed()
1033 png_app_warning(png_ptr, in png_set_rgb_to_gray_fixed()
1042 if (png_ptr->rgb_to_gray_red_coeff == 0 && in png_set_rgb_to_gray_fixed()
1043 png_ptr->rgb_to_gray_green_coeff == 0) in png_set_rgb_to_gray_fixed()
1045 png_ptr->rgb_to_gray_red_coeff = 6968; in png_set_rgb_to_gray_fixed()
1046 png_ptr->rgb_to_gray_green_coeff = 23434; in png_set_rgb_to_gray_fixed()
1059 png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red, in png_set_rgb_to_gray() argument
1062 png_set_rgb_to_gray_fixed(png_ptr, error_action, in png_set_rgb_to_gray()
1063 png_fixed(png_ptr, red, "rgb to gray red coefficient"), in png_set_rgb_to_gray()
1064 png_fixed(png_ptr, green, "rgb to gray green coefficient")); in png_set_rgb_to_gray()
1073 png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr in png_set_read_user_transform_fn() argument
1079 png_ptr->transformations |= PNG_USER_TRANSFORM; in png_set_read_user_transform_fn()
1080 png_ptr->read_user_transform_fn = read_user_transform_fn; in png_set_read_user_transform_fn()
1117 png_init_palette_transformations(png_structrp png_ptr) in png_init_palette_transformations() argument
1130 if (png_ptr->num_trans > 0) in png_init_palette_transformations()
1135 for (i=0; i<png_ptr->num_trans; ++i) in png_init_palette_transformations()
1137 if (png_ptr->trans_alpha[i] == 255) in png_init_palette_transformations()
1139 else if (png_ptr->trans_alpha[i] == 0) in png_init_palette_transformations()
1157 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_init_palette_transformations()
1158 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_init_palette_transformations()
1161 png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); in png_init_palette_transformations()
1173 if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 && in png_init_palette_transformations()
1174 (png_ptr->transformations & PNG_EXPAND) != 0) in png_init_palette_transformations()
1177 png_ptr->background.red = in png_init_palette_transformations()
1178 png_ptr->palette[png_ptr->background.index].red; in png_init_palette_transformations()
1179 png_ptr->background.green = in png_init_palette_transformations()
1180 png_ptr->palette[png_ptr->background.index].green; in png_init_palette_transformations()
1181 png_ptr->background.blue = in png_init_palette_transformations()
1182 png_ptr->palette[png_ptr->background.index].blue; in png_init_palette_transformations()
1185 if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) in png_init_palette_transformations()
1187 if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0) in png_init_palette_transformations()
1192 int i, istop = png_ptr->num_trans; in png_init_palette_transformations()
1195 png_ptr->trans_alpha[i] = in png_init_palette_transformations()
1196 (png_byte)(255 - png_ptr->trans_alpha[i]); in png_init_palette_transformations()
1206 png_init_rgb_transformations(png_structrp png_ptr) in png_init_rgb_transformations() argument
1212 int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0; in png_init_rgb_transformations()
1213 int input_has_transparency = png_ptr->num_trans > 0; in png_init_rgb_transformations()
1223 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_init_rgb_transformations()
1224 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_init_rgb_transformations()
1228 png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); in png_init_rgb_transformations()
1240 if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 && in png_init_rgb_transformations()
1241 (png_ptr->transformations & PNG_EXPAND) != 0 && in png_init_rgb_transformations()
1242 (png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) in png_init_rgb_transformations()
1247 int gray = png_ptr->background.gray; in png_init_rgb_transformations()
1248 int trans_gray = png_ptr->trans_color.gray; in png_init_rgb_transformations()
1250 switch (png_ptr->bit_depth) in png_init_rgb_transformations()
1277 png_ptr->background.red = png_ptr->background.green = in png_init_rgb_transformations()
1278 png_ptr->background.blue = (png_uint_16)gray; in png_init_rgb_transformations()
1280 if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0) in png_init_rgb_transformations()
1282 png_ptr->trans_color.red = png_ptr->trans_color.green = in png_init_rgb_transformations()
1283 png_ptr->trans_color.blue = (png_uint_16)trans_gray; in png_init_rgb_transformations()
1291 png_init_read_transformations(png_structrp png_ptr) in png_init_read_transformations() argument
1316 if (png_ptr->colorspace.gamma != 0) /* has been set */ in png_init_read_transformations()
1318 if (png_ptr->screen_gamma != 0) /* screen set too */ in png_init_read_transformations()
1319 gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma, in png_init_read_transformations()
1320 png_ptr->screen_gamma); in png_init_read_transformations()
1326 png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma); in png_init_read_transformations()
1329 else if (png_ptr->screen_gamma != 0) in png_init_read_transformations()
1335 png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma); in png_init_read_transformations()
1343 png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1; in png_init_read_transformations()
1346 png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; in png_init_read_transformations()
1357 png_ptr->transformations |= PNG_GAMMA; in png_init_read_transformations()
1360 png_ptr->transformations &= ~PNG_GAMMA; in png_init_read_transformations()
1394 if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 && in png_init_read_transformations()
1395 (png_ptr->transformations & PNG_COMPOSE) == 0) in png_init_read_transformations()
1402 png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA | in png_init_read_transformations()
1404 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_init_read_transformations()
1413 png_ptr->num_trans = 0; in png_init_read_transformations()
1421 if (png_gamma_significant(png_ptr->screen_gamma) == 0) in png_init_read_transformations()
1423 png_ptr->transformations &= ~PNG_ENCODE_ALPHA; in png_init_read_transformations()
1424 png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; in png_init_read_transformations()
1432 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) in png_init_read_transformations()
1433 png_colorspace_set_rgb_coefficients(png_ptr); in png_init_read_transformations()
1453 if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0) in png_init_read_transformations()
1458 if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) in png_init_read_transformations()
1459 png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; in png_init_read_transformations()
1462 else if ((png_ptr->transformations & PNG_COMPOSE) != 0) in png_init_read_transformations()
1469 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0) in png_init_read_transformations()
1471 if (png_ptr->background.red == png_ptr->background.green && in png_init_read_transformations()
1472 png_ptr->background.red == png_ptr->background.blue) in png_init_read_transformations()
1474 png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; in png_init_read_transformations()
1475 png_ptr->background.gray = png_ptr->background.red; in png_init_read_transformations()
1493 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_init_read_transformations()
1494 png_init_palette_transformations(png_ptr); in png_init_read_transformations()
1497 png_init_rgb_transformations(png_ptr); in png_init_read_transformations()
1501 if ((png_ptr->transformations & PNG_EXPAND_16) != 0 && in png_init_read_transformations()
1502 (png_ptr->transformations & PNG_COMPOSE) != 0 && in png_init_read_transformations()
1503 (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 && in png_init_read_transformations()
1504 png_ptr->bit_depth != 16) in png_init_read_transformations()
1517 CHOP(png_ptr->background.red); in png_init_read_transformations()
1518 CHOP(png_ptr->background.green); in png_init_read_transformations()
1519 CHOP(png_ptr->background.blue); in png_init_read_transformations()
1520 CHOP(png_ptr->background.gray); in png_init_read_transformations()
1528 if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) != 0 && in png_init_read_transformations()
1529 (png_ptr->transformations & PNG_COMPOSE) != 0 && in png_init_read_transformations()
1530 (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 && in png_init_read_transformations()
1531 png_ptr->bit_depth == 16) in png_init_read_transformations()
1539 png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257); in png_init_read_transformations()
1540 png_ptr->background.green = in png_init_read_transformations()
1541 (png_uint_16)(png_ptr->background.green * 257); in png_init_read_transformations()
1542 png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257); in png_init_read_transformations()
1543 png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257); in png_init_read_transformations()
1558 png_ptr->background_1 = png_ptr->background; in png_init_read_transformations()
1574 if ((png_ptr->transformations & PNG_GAMMA) != 0 || in png_init_read_transformations()
1575 ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0 && in png_init_read_transformations()
1576 (png_gamma_significant(png_ptr->colorspace.gamma) != 0 || in png_init_read_transformations()
1577 png_gamma_significant(png_ptr->screen_gamma) != 0)) || in png_init_read_transformations()
1578 ((png_ptr->transformations & PNG_COMPOSE) != 0 && in png_init_read_transformations()
1579 (png_gamma_significant(png_ptr->colorspace.gamma) != 0 || in png_init_read_transformations()
1580 png_gamma_significant(png_ptr->screen_gamma) != 0 in png_init_read_transformations()
1582 || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE && in png_init_read_transformations()
1583 png_gamma_significant(png_ptr->background_gamma) != 0) in png_init_read_transformations()
1585 )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 && in png_init_read_transformations()
1586 png_gamma_significant(png_ptr->screen_gamma) != 0)) in png_init_read_transformations()
1588 png_build_gamma_table(png_ptr, png_ptr->bit_depth); in png_init_read_transformations()
1591 if ((png_ptr->transformations & PNG_COMPOSE) != 0) in png_init_read_transformations()
1599 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) in png_init_read_transformations()
1600 png_warning(png_ptr, in png_init_read_transformations()
1603 if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0) in png_init_read_transformations()
1609 png_colorp palette = png_ptr->palette; in png_init_read_transformations()
1610 int num_palette = png_ptr->num_palette; in png_init_read_transformations()
1612 if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) in png_init_read_transformations()
1615 back.red = png_ptr->gamma_table[png_ptr->background.red]; in png_init_read_transformations()
1616 back.green = png_ptr->gamma_table[png_ptr->background.green]; in png_init_read_transformations()
1617 back.blue = png_ptr->gamma_table[png_ptr->background.blue]; in png_init_read_transformations()
1619 back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; in png_init_read_transformations()
1620 back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; in png_init_read_transformations()
1621 back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; in png_init_read_transformations()
1627 switch (png_ptr->background_gamma_type) in png_init_read_transformations()
1630 g = (png_ptr->screen_gamma); in png_init_read_transformations()
1635 g = png_reciprocal(png_ptr->colorspace.gamma); in png_init_read_transformations()
1636 gs = png_reciprocal2(png_ptr->colorspace.gamma, in png_init_read_transformations()
1637 png_ptr->screen_gamma); in png_init_read_transformations()
1641 g = png_reciprocal(png_ptr->background_gamma); in png_init_read_transformations()
1642 gs = png_reciprocal2(png_ptr->background_gamma, in png_init_read_transformations()
1643 png_ptr->screen_gamma); in png_init_read_transformations()
1653 back.red = png_gamma_8bit_correct(png_ptr->background.red, in png_init_read_transformations()
1655 back.green = png_gamma_8bit_correct(png_ptr->background.green, in png_init_read_transformations()
1657 back.blue = png_gamma_8bit_correct(png_ptr->background.blue, in png_init_read_transformations()
1663 back.red = (png_byte)png_ptr->background.red; in png_init_read_transformations()
1664 back.green = (png_byte)png_ptr->background.green; in png_init_read_transformations()
1665 back.blue = (png_byte)png_ptr->background.blue; in png_init_read_transformations()
1670 back_1.red = png_gamma_8bit_correct(png_ptr->background.red, in png_init_read_transformations()
1673 png_ptr->background.green, g); in png_init_read_transformations()
1674 back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue, in png_init_read_transformations()
1680 back_1.red = (png_byte)png_ptr->background.red; in png_init_read_transformations()
1681 back_1.green = (png_byte)png_ptr->background.green; in png_init_read_transformations()
1682 back_1.blue = (png_byte)png_ptr->background.blue; in png_init_read_transformations()
1688 if (i < (int)png_ptr->num_trans && in png_init_read_transformations()
1689 png_ptr->trans_alpha[i] != 0xff) in png_init_read_transformations()
1691 if (png_ptr->trans_alpha[i] == 0) in png_init_read_transformations()
1699 v = png_ptr->gamma_to_1[palette[i].red]; in png_init_read_transformations()
1700 png_composite(w, v, png_ptr->trans_alpha[i], back_1.red); in png_init_read_transformations()
1701 palette[i].red = png_ptr->gamma_from_1[w]; in png_init_read_transformations()
1703 v = png_ptr->gamma_to_1[palette[i].green]; in png_init_read_transformations()
1704 png_composite(w, v, png_ptr->trans_alpha[i], back_1.green); in png_init_read_transformations()
1705 palette[i].green = png_ptr->gamma_from_1[w]; in png_init_read_transformations()
1707 v = png_ptr->gamma_to_1[palette[i].blue]; in png_init_read_transformations()
1708 png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue); in png_init_read_transformations()
1709 palette[i].blue = png_ptr->gamma_from_1[w]; in png_init_read_transformations()
1714 palette[i].red = png_ptr->gamma_table[palette[i].red]; in png_init_read_transformations()
1715 palette[i].green = png_ptr->gamma_table[palette[i].green]; in png_init_read_transformations()
1716 palette[i].blue = png_ptr->gamma_table[palette[i].blue]; in png_init_read_transformations()
1726 png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA); in png_init_read_transformations()
1736 switch (png_ptr->background_gamma_type) in png_init_read_transformations()
1739 g = png_ptr->screen_gamma; in png_init_read_transformations()
1744 g = png_reciprocal(png_ptr->colorspace.gamma); in png_init_read_transformations()
1745 gs = png_reciprocal2(png_ptr->colorspace.gamma, in png_init_read_transformations()
1746 png_ptr->screen_gamma); in png_init_read_transformations()
1750 g = png_reciprocal(png_ptr->background_gamma); in png_init_read_transformations()
1751 gs = png_reciprocal2(png_ptr->background_gamma, in png_init_read_transformations()
1752 png_ptr->screen_gamma); in png_init_read_transformations()
1756 png_error(png_ptr, "invalid background gamma type"); in png_init_read_transformations()
1763 png_ptr->background_1.gray = png_gamma_correct(png_ptr, in png_init_read_transformations()
1764 png_ptr->background.gray, g); in png_init_read_transformations()
1767 png_ptr->background.gray = png_gamma_correct(png_ptr, in png_init_read_transformations()
1768 png_ptr->background.gray, gs); in png_init_read_transformations()
1770 if ((png_ptr->background.red != png_ptr->background.green) || in png_init_read_transformations()
1771 (png_ptr->background.red != png_ptr->background.blue) || in png_init_read_transformations()
1772 (png_ptr->background.red != png_ptr->background.gray)) in png_init_read_transformations()
1777 png_ptr->background_1.red = png_gamma_correct(png_ptr, in png_init_read_transformations()
1778 png_ptr->background.red, g); in png_init_read_transformations()
1780 png_ptr->background_1.green = png_gamma_correct(png_ptr, in png_init_read_transformations()
1781 png_ptr->background.green, g); in png_init_read_transformations()
1783 png_ptr->background_1.blue = png_gamma_correct(png_ptr, in png_init_read_transformations()
1784 png_ptr->background.blue, g); in png_init_read_transformations()
1789 png_ptr->background.red = png_gamma_correct(png_ptr, in png_init_read_transformations()
1790 png_ptr->background.red, gs); in png_init_read_transformations()
1792 png_ptr->background.green = png_gamma_correct(png_ptr, in png_init_read_transformations()
1793 png_ptr->background.green, gs); in png_init_read_transformations()
1795 png_ptr->background.blue = png_gamma_correct(png_ptr, in png_init_read_transformations()
1796 png_ptr->background.blue, gs); in png_init_read_transformations()
1803 png_ptr->background_1.red = png_ptr->background_1.green in png_init_read_transformations()
1804 = png_ptr->background_1.blue = png_ptr->background_1.gray; in png_init_read_transformations()
1806 png_ptr->background.red = png_ptr->background.green in png_init_read_transformations()
1807 = png_ptr->background.blue = png_ptr->background.gray; in png_init_read_transformations()
1811 png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN; in png_init_read_transformations()
1818 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE in png_init_read_transformations()
1821 && ((png_ptr->transformations & PNG_EXPAND) == 0 || in png_init_read_transformations()
1822 (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) in png_init_read_transformations()
1826 png_colorp palette = png_ptr->palette; in png_init_read_transformations()
1827 int num_palette = png_ptr->num_palette; in png_init_read_transformations()
1835 palette[i].red = png_ptr->gamma_table[palette[i].red]; in png_init_read_transformations()
1836 palette[i].green = png_ptr->gamma_table[palette[i].green]; in png_init_read_transformations()
1837 palette[i].blue = png_ptr->gamma_table[palette[i].blue]; in png_init_read_transformations()
1841 png_ptr->transformations &= ~PNG_GAMMA; in png_init_read_transformations()
1851 if ((png_ptr->transformations & PNG_COMPOSE) != 0 && in png_init_read_transformations()
1852 (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) in png_init_read_transformations()
1855 int istop = (int)png_ptr->num_trans; in png_init_read_transformations()
1857 png_colorp palette = png_ptr->palette; in png_init_read_transformations()
1859 back.red = (png_byte)png_ptr->background.red; in png_init_read_transformations()
1860 back.green = (png_byte)png_ptr->background.green; in png_init_read_transformations()
1861 back.blue = (png_byte)png_ptr->background.blue; in png_init_read_transformations()
1865 if (png_ptr->trans_alpha[i] == 0) in png_init_read_transformations()
1870 else if (png_ptr->trans_alpha[i] != 0xff) in png_init_read_transformations()
1874 png_ptr->trans_alpha[i], back.red); in png_init_read_transformations()
1877 png_ptr->trans_alpha[i], back.green); in png_init_read_transformations()
1880 png_ptr->trans_alpha[i], back.blue); in png_init_read_transformations()
1884 png_ptr->transformations &= ~PNG_COMPOSE; in png_init_read_transformations()
1889 if ((png_ptr->transformations & PNG_SHIFT) != 0 && in png_init_read_transformations()
1890 (png_ptr->transformations & PNG_EXPAND) == 0 && in png_init_read_transformations()
1891 (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) in png_init_read_transformations()
1894 int istop = png_ptr->num_palette; in png_init_read_transformations()
1895 int shift = 8 - png_ptr->sig_bit.red; in png_init_read_transformations()
1897 png_ptr->transformations &= ~PNG_SHIFT; in png_init_read_transformations()
1906 int component = png_ptr->palette[i].red; in png_init_read_transformations()
1909 png_ptr->palette[i].red = (png_byte)component; in png_init_read_transformations()
1912 shift = 8 - png_ptr->sig_bit.green; in png_init_read_transformations()
1916 int component = png_ptr->palette[i].green; in png_init_read_transformations()
1919 png_ptr->palette[i].green = (png_byte)component; in png_init_read_transformations()
1922 shift = 8 - png_ptr->sig_bit.blue; in png_init_read_transformations()
1926 int component = png_ptr->palette[i].blue; in png_init_read_transformations()
1929 png_ptr->palette[i].blue = (png_byte)component; in png_init_read_transformations()
1940 png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) in png_read_transform_info() argument
1945 if ((png_ptr->transformations & PNG_EXPAND) != 0) in png_read_transform_info()
1953 if (png_ptr->num_trans > 0) in png_read_transform_info()
1962 if (png_ptr->palette == NULL) in png_read_transform_info()
1963 png_error (png_ptr, "Palette is NULL in indexed image"); in png_read_transform_info()
1967 if (png_ptr->num_trans != 0) in png_read_transform_info()
1969 if ((png_ptr->transformations & PNG_EXPAND_tRNS) != 0) in png_read_transform_info()
1985 if ((png_ptr->transformations & PNG_COMPOSE) != 0) in png_read_transform_info()
1986 info_ptr->background = png_ptr->background; in png_read_transform_info()
1999 info_ptr->colorspace.gamma = png_ptr->colorspace.gamma; in png_read_transform_info()
2006 if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0) in png_read_transform_info()
2011 if ((png_ptr->transformations & PNG_16_TO_8) != 0) in png_read_transform_info()
2025 png_ptr->transformations |= PNG_16_TO_8; in png_read_transform_info()
2030 png_ptr->transformations |= PNG_SCALE_16_TO_8; in png_read_transform_info()
2041 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0) in png_read_transform_info()
2047 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) in png_read_transform_info()
2053 if ((png_ptr->transformations & PNG_QUANTIZE) != 0) in png_read_transform_info()
2057 png_ptr->palette_lookup != 0 && info_ptr->bit_depth == 8) in png_read_transform_info()
2065 if ((png_ptr->transformations & PNG_EXPAND_16) != 0 && in png_read_transform_info()
2074 if ((png_ptr->transformations & PNG_PACK) != 0 && in png_read_transform_info()
2089 if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0) in png_read_transform_info()
2102 if ((png_ptr->transformations & PNG_FILLER) != 0 && in png_read_transform_info()
2108 if ((png_ptr->transformations & PNG_ADD_ALPHA) != 0) in png_read_transform_info()
2115 if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) in png_read_transform_info()
2117 if (png_ptr->user_transform_depth != 0) in png_read_transform_info()
2118 info_ptr->bit_depth = png_ptr->user_transform_depth; in png_read_transform_info()
2120 if (png_ptr->user_transform_channels != 0) in png_read_transform_info()
2121 info_ptr->channels = png_ptr->user_transform_channels; in png_read_transform_info()
2136 png_ptr->info_rowbytes = info_ptr->rowbytes; in png_read_transform_info()
2139 if (png_ptr != NULL) in png_read_transform_info()
2999 png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) in png_do_rgb_to_gray() argument
3008 png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; in png_do_rgb_to_gray()
3009 png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; in png_do_rgb_to_gray()
3022 if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) in png_do_rgb_to_gray()
3036 red = png_ptr->gamma_to_1[red]; in png_do_rgb_to_gray()
3037 green = png_ptr->gamma_to_1[green]; in png_do_rgb_to_gray()
3038 blue = png_ptr->gamma_to_1[blue]; in png_do_rgb_to_gray()
3041 *(dp++) = png_ptr->gamma_from_1[ in png_do_rgb_to_gray()
3050 if (png_ptr->gamma_table != NULL) in png_do_rgb_to_gray()
3051 red = png_ptr->gamma_table[red]; in png_do_rgb_to_gray()
3094 if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL) in png_do_rgb_to_gray()
3111 if (png_ptr->gamma_16_table != NULL) in png_do_rgb_to_gray()
3112 w = png_ptr->gamma_16_table[(red & 0xff) in png_do_rgb_to_gray()
3113 >> png_ptr->gamma_shift][red >> 8]; in png_do_rgb_to_gray()
3121 png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red & 0xff) in png_do_rgb_to_gray()
3122 >> png_ptr->gamma_shift][red>>8]; in png_do_rgb_to_gray()
3124 png_ptr->gamma_16_to_1[(green & 0xff) >> in png_do_rgb_to_gray()
3125 png_ptr->gamma_shift][green>>8]; in png_do_rgb_to_gray()
3126 png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue & 0xff) in png_do_rgb_to_gray()
3127 >> png_ptr->gamma_shift][blue>>8]; in png_do_rgb_to_gray()
3130 w = png_ptr->gamma_16_from_1[(gray16 & 0xff) >> in png_do_rgb_to_gray()
3131 png_ptr->gamma_shift][gray16 >> 8]; in png_do_rgb_to_gray()
3200 png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) in png_do_compose() argument
3203 png_const_bytep gamma_table = png_ptr->gamma_table; in png_do_compose()
3204 png_const_bytep gamma_from_1 = png_ptr->gamma_from_1; in png_do_compose()
3205 png_const_bytep gamma_to_1 = png_ptr->gamma_to_1; in png_do_compose()
3206 png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table; in png_do_compose()
3207 png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1; in png_do_compose()
3208 png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1; in png_do_compose()
3209 int gamma_shift = png_ptr->gamma_shift; in png_do_compose()
3210 int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0; in png_do_compose()
3233 == png_ptr->trans_color.gray) in png_do_compose()
3237 (unsigned int)(png_ptr->background.gray << shift); in png_do_compose()
3263 == png_ptr->trans_color.gray) in png_do_compose()
3267 (unsigned int)png_ptr->background.gray << shift; in png_do_compose()
3300 == png_ptr->trans_color.gray) in png_do_compose()
3304 (unsigned int)png_ptr->background.gray << shift; in png_do_compose()
3331 == png_ptr->trans_color.gray) in png_do_compose()
3335 (unsigned int)(png_ptr->background.gray << shift); in png_do_compose()
3368 == png_ptr->trans_color.gray) in png_do_compose()
3372 (unsigned int)(png_ptr->background.gray << shift); in png_do_compose()
3397 if (*sp == png_ptr->trans_color.gray) in png_do_compose()
3398 *sp = (png_byte)png_ptr->background.gray; in png_do_compose()
3410 if (*sp == png_ptr->trans_color.gray) in png_do_compose()
3411 *sp = (png_byte)png_ptr->background.gray; in png_do_compose()
3429 if (v == png_ptr->trans_color.gray) in png_do_compose()
3432 *sp = (png_byte)((png_ptr->background.gray >> 8) in png_do_compose()
3434 *(sp + 1) = (png_byte)(png_ptr->background.gray in png_do_compose()
3456 if (v == png_ptr->trans_color.gray) in png_do_compose()
3458 *sp = (png_byte)((png_ptr->background.gray >> 8) in png_do_compose()
3460 *(sp + 1) = (png_byte)(png_ptr->background.gray in png_do_compose()
3484 if (*sp == png_ptr->trans_color.red && in png_do_compose()
3485 *(sp + 1) == png_ptr->trans_color.green && in png_do_compose()
3486 *(sp + 2) == png_ptr->trans_color.blue) in png_do_compose()
3488 *sp = (png_byte)png_ptr->background.red; in png_do_compose()
3489 *(sp + 1) = (png_byte)png_ptr->background.green; in png_do_compose()
3490 *(sp + 2) = (png_byte)png_ptr->background.blue; in png_do_compose()
3507 if (*sp == png_ptr->trans_color.red && in png_do_compose()
3508 *(sp + 1) == png_ptr->trans_color.green && in png_do_compose()
3509 *(sp + 2) == png_ptr->trans_color.blue) in png_do_compose()
3511 *sp = (png_byte)png_ptr->background.red; in png_do_compose()
3512 *(sp + 1) = (png_byte)png_ptr->background.green; in png_do_compose()
3513 *(sp + 2) = (png_byte)png_ptr->background.blue; in png_do_compose()
3534 if (r == png_ptr->trans_color.red && in png_do_compose()
3535 g == png_ptr->trans_color.green && in png_do_compose()
3536 b == png_ptr->trans_color.blue) in png_do_compose()
3539 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); in png_do_compose()
3540 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); in png_do_compose()
3541 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) in png_do_compose()
3543 *(sp + 3) = (png_byte)(png_ptr->background.green in png_do_compose()
3545 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) in png_do_compose()
3547 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); in png_do_compose()
3581 if (r == png_ptr->trans_color.red && in png_do_compose()
3582 g == png_ptr->trans_color.green && in png_do_compose()
3583 b == png_ptr->trans_color.blue) in png_do_compose()
3585 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); in png_do_compose()
3586 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); in png_do_compose()
3587 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) in png_do_compose()
3589 *(sp + 3) = (png_byte)(png_ptr->background.green in png_do_compose()
3591 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) in png_do_compose()
3593 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); in png_do_compose()
3620 *sp = (png_byte)png_ptr->background.gray; in png_do_compose()
3628 png_composite(w, v, a, png_ptr->background_1.gray); in png_do_compose()
3644 *sp = (png_byte)png_ptr->background.gray; in png_do_compose()
3647 png_composite(*sp, *sp, a, png_ptr->background.gray); in png_do_compose()
3675 *sp = (png_byte)((png_ptr->background.gray >> 8) in png_do_compose()
3677 *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); in png_do_compose()
3685 png_composite_16(v, g, a, png_ptr->background_1.gray); in png_do_compose()
3707 *sp = (png_byte)((png_ptr->background.gray >> 8) in png_do_compose()
3709 *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); in png_do_compose()
3717 png_composite_16(v, g, a, png_ptr->background.gray); in png_do_compose()
3750 *sp = (png_byte)png_ptr->background.red; in png_do_compose()
3751 *(sp + 1) = (png_byte)png_ptr->background.green; in png_do_compose()
3752 *(sp + 2) = (png_byte)png_ptr->background.blue; in png_do_compose()
3760 png_composite(w, v, a, png_ptr->background_1.red); in png_do_compose()
3765 png_composite(w, v, a, png_ptr->background_1.green); in png_do_compose()
3770 png_composite(w, v, a, png_ptr->background_1.blue); in png_do_compose()
3786 *sp = (png_byte)png_ptr->background.red; in png_do_compose()
3787 *(sp + 1) = (png_byte)png_ptr->background.green; in png_do_compose()
3788 *(sp + 2) = (png_byte)png_ptr->background.blue; in png_do_compose()
3793 png_composite(*sp, *sp, a, png_ptr->background.red); in png_do_compose()
3796 png_ptr->background.green); in png_do_compose()
3799 png_ptr->background.blue); in png_do_compose()
3836 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); in png_do_compose()
3837 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); in png_do_compose()
3838 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) in png_do_compose()
3840 *(sp + 3) = (png_byte)(png_ptr->background.green in png_do_compose()
3842 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) in png_do_compose()
3844 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); in png_do_compose()
3852 png_composite_16(w, v, a, png_ptr->background_1.red); in png_do_compose()
3860 png_composite_16(w, v, a, png_ptr->background_1.green); in png_do_compose()
3869 png_composite_16(w, v, a, png_ptr->background_1.blue); in png_do_compose()
3891 *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); in png_do_compose()
3892 *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); in png_do_compose()
3893 *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) in png_do_compose()
3895 *(sp + 3) = (png_byte)(png_ptr->background.green in png_do_compose()
3897 *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) in png_do_compose()
3899 *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); in png_do_compose()
3912 png_composite_16(v, r, a, png_ptr->background.red); in png_do_compose()
3916 png_composite_16(v, g, a, png_ptr->background.green); in png_do_compose()
3920 png_composite_16(v, b, a, png_ptr->background.blue); in png_do_compose()
3944 png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) in png_do_gamma() argument
3946 png_const_bytep gamma_table = png_ptr->gamma_table; in png_do_gamma()
3947 png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table; in png_do_gamma()
3948 int gamma_shift = png_ptr->gamma_shift; in png_do_gamma()
4145 png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) in png_do_encode_alpha() argument
4155 png_bytep table = png_ptr->gamma_from_1; in png_do_encode_alpha()
4173 png_uint_16pp table = png_ptr->gamma_16_from_1; in png_do_encode_alpha()
4174 int gamma_shift = png_ptr->gamma_shift; in png_do_encode_alpha()
4200 png_warning(png_ptr, "png_do_encode_alpha: unexpected call"); in png_do_encode_alpha()
4209 png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info, in png_do_expand_palette() argument
4317 if (png_ptr->riffled_palette != NULL) in png_do_expand_palette()
4323 i = png_do_expand_palette_rgba8_neon(png_ptr, row_info, row, in png_do_expand_palette()
4327 PNG_UNUSED(png_ptr) in png_do_expand_palette()
4354 i = png_do_expand_palette_rgb8_neon(png_ptr, row_info, row, in png_do_expand_palette()
4357 PNG_UNUSED(png_ptr) in png_do_expand_palette()
4740 png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) in png_do_read_transformations() argument
4744 if (png_ptr->row_buf == NULL) in png_do_read_transformations()
4750 png_error(png_ptr, "NULL row buffer"); in png_do_read_transformations()
4759 if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 && in png_do_read_transformations()
4760 (png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) in png_do_read_transformations()
4766 png_error(png_ptr, "Uninitialized row"); in png_do_read_transformations()
4770 if ((png_ptr->transformations & PNG_EXPAND) != 0) in png_do_read_transformations()
4775 if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8)) in png_do_read_transformations()
4777 if (png_ptr->riffled_palette == NULL) in png_do_read_transformations()
4780 png_ptr->riffled_palette = in png_do_read_transformations()
4781 (png_bytep)png_malloc(png_ptr, 256 * 4); in png_do_read_transformations()
4782 png_riffle_palette_neon(png_ptr); in png_do_read_transformations()
4786 png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
4787 png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans); in png_do_read_transformations()
4792 if (png_ptr->num_trans != 0 && in png_do_read_transformations()
4793 (png_ptr->transformations & PNG_EXPAND_tRNS) != 0) in png_do_read_transformations()
4794 png_do_expand(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
4795 &(png_ptr->trans_color)); in png_do_read_transformations()
4798 png_do_expand(row_info, png_ptr->row_buf + 1, NULL); in png_do_read_transformations()
4804 if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 && in png_do_read_transformations()
4805 (png_ptr->transformations & PNG_COMPOSE) == 0 && in png_do_read_transformations()
4808 png_do_strip_channel(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
4813 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) in png_do_read_transformations()
4816 png_do_rgb_to_gray(png_ptr, row_info, in png_do_read_transformations()
4817 png_ptr->row_buf + 1); in png_do_read_transformations()
4821 png_ptr->rgb_to_gray_status=1; in png_do_read_transformations()
4822 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == in png_do_read_transformations()
4824 png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); in png_do_read_transformations()
4826 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == in png_do_read_transformations()
4828 png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); in png_do_read_transformations()
4868 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 && in png_do_read_transformations()
4869 (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) == 0) in png_do_read_transformations()
4870 png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4875 if ((png_ptr->transformations & PNG_COMPOSE) != 0) in png_do_read_transformations()
4876 png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr); in png_do_read_transformations()
4880 if ((png_ptr->transformations & PNG_GAMMA) != 0 && in png_do_read_transformations()
4883 (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0 && in png_do_read_transformations()
4890 !((png_ptr->transformations & PNG_COMPOSE) != 0 && in png_do_read_transformations()
4891 ((png_ptr->num_trans != 0) || in png_do_read_transformations()
4892 (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) && in png_do_read_transformations()
4897 (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) in png_do_read_transformations()
4898 png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr); in png_do_read_transformations()
4902 if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 && in png_do_read_transformations()
4903 (png_ptr->transformations & PNG_COMPOSE) != 0 && in png_do_read_transformations()
4906 png_do_strip_channel(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
4911 if ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 && in png_do_read_transformations()
4913 png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr); in png_do_read_transformations()
4917 if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0) in png_do_read_transformations()
4918 png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4926 if ((png_ptr->transformations & PNG_16_TO_8) != 0) in png_do_read_transformations()
4927 png_do_chop(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4931 if ((png_ptr->transformations & PNG_QUANTIZE) != 0) in png_do_read_transformations()
4933 png_do_quantize(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
4934 png_ptr->palette_lookup, png_ptr->quantize_index); in png_do_read_transformations()
4937 png_error(png_ptr, "png_do_quantize returned rowbytes=0"); in png_do_read_transformations()
4947 if ((png_ptr->transformations & PNG_EXPAND_16) != 0) in png_do_read_transformations()
4948 png_do_expand_16(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4953 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 && in png_do_read_transformations()
4954 (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) != 0) in png_do_read_transformations()
4955 png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4959 if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) in png_do_read_transformations()
4960 png_do_invert(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4964 if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) in png_do_read_transformations()
4965 png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4969 if ((png_ptr->transformations & PNG_SHIFT) != 0) in png_do_read_transformations()
4970 png_do_unshift(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
4971 &(png_ptr->shift)); in png_do_read_transformations()
4975 if ((png_ptr->transformations & PNG_PACK) != 0) in png_do_read_transformations()
4976 png_do_unpack(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4982 png_ptr->num_palette_max >= 0) in png_do_read_transformations()
4983 png_do_check_palette_indexes(png_ptr, row_info); in png_do_read_transformations()
4987 if ((png_ptr->transformations & PNG_BGR) != 0) in png_do_read_transformations()
4988 png_do_bgr(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4992 if ((png_ptr->transformations & PNG_PACKSWAP) != 0) in png_do_read_transformations()
4993 png_do_packswap(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
4997 if ((png_ptr->transformations & PNG_FILLER) != 0) in png_do_read_transformations()
4998 png_do_read_filler(row_info, png_ptr->row_buf + 1, in png_do_read_transformations()
4999 (png_uint_32)png_ptr->filler, png_ptr->flags); in png_do_read_transformations()
5003 if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0) in png_do_read_transformations()
5004 png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
5009 if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) in png_do_read_transformations()
5010 png_do_swap(row_info, png_ptr->row_buf + 1); in png_do_read_transformations()
5015 if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) in png_do_read_transformations()
5017 if (png_ptr->read_user_transform_fn != NULL) in png_do_read_transformations()
5018 (*(png_ptr->read_user_transform_fn)) /* User read transform function */ in png_do_read_transformations()
5019 (png_ptr, /* png_ptr */ in png_do_read_transformations()
5027 png_ptr->row_buf + 1); /* start of pixel data for row */ in png_do_read_transformations()
5029 if (png_ptr->user_transform_depth != 0) in png_do_read_transformations()
5030 row_info->bit_depth = png_ptr->user_transform_depth; in png_do_read_transformations()
5032 if (png_ptr->user_transform_channels != 0) in png_do_read_transformations()
5033 row_info->channels = png_ptr->user_transform_channels; in png_do_read_transformations()