Lines Matching refs:png_ptr
26 png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) in png_set_crc_action() argument
30 if (png_ptr == NULL) in png_set_crc_action()
40 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; in png_set_crc_action()
41 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; in png_set_crc_action()
45 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; in png_set_crc_action()
46 png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | in png_set_crc_action()
51 png_warning(png_ptr, in png_set_crc_action()
57 png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; in png_set_crc_action()
68 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
69 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; in png_set_crc_action()
73 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
74 png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | 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_NOWARN; in png_set_crc_action()
87 png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; in png_set_crc_action()
96 png_set_background(png_structp png_ptr, in png_set_background() argument
102 if (png_ptr == NULL) in png_set_background()
106 png_warning(png_ptr, "Application must supply a known background gamma"); in png_set_background()
110 png_ptr->transformations |= PNG_BACKGROUND; in png_set_background()
111 png_memcpy(&(png_ptr->background), background_color, in png_set_background()
113 png_ptr->background_gamma = (float)background_gamma; in png_set_background()
114 png_ptr->background_gamma_type = (png_byte)(background_gamma_code); in png_set_background()
115 png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0); in png_set_background()
122 png_set_strip_16(png_structp png_ptr) in png_set_strip_16() argument
126 if (png_ptr == NULL) in png_set_strip_16()
128 png_ptr->transformations |= PNG_16_TO_8; in png_set_strip_16()
134 png_set_strip_alpha(png_structp png_ptr) in png_set_strip_alpha() argument
138 if (png_ptr == NULL) in png_set_strip_alpha()
140 png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; in png_set_strip_alpha()
164 png_set_dither(png_structp png_ptr, png_colorp palette, in png_set_dither() argument
170 if (png_ptr == NULL) in png_set_dither()
172 png_ptr->transformations |= PNG_DITHER; in png_set_dither()
178 png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, in png_set_dither()
181 png_ptr->dither_index[i] = (png_byte)i; in png_set_dither()
195 png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, in png_set_dither()
200 png_ptr->dither_sort[i] = (png_byte)i; in png_set_dither()
217 if (histogram[png_ptr->dither_sort[j]] in png_set_dither()
218 < histogram[png_ptr->dither_sort[j + 1]]) in png_set_dither()
222 t = png_ptr->dither_sort[j]; in png_set_dither()
223 png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1]; in png_set_dither()
224 png_ptr->dither_sort[j + 1] = t; in png_set_dither()
242 if ((int)png_ptr->dither_sort[i] >= maximum_colors) in png_set_dither()
246 while ((int)png_ptr->dither_sort[j] >= maximum_colors); in png_set_dither()
261 if ((int)png_ptr->dither_sort[i] >= maximum_colors) in png_set_dither()
267 while ((int)png_ptr->dither_sort[j] >= maximum_colors); in png_set_dither()
273 png_ptr->dither_index[j] = (png_byte)i; in png_set_dither()
274 png_ptr->dither_index[i] = (png_byte)j; in png_set_dither()
281 if ((int)png_ptr->dither_index[i] >= maximum_colors) in png_set_dither()
286 d_index = png_ptr->dither_index[i]; in png_set_dither()
301 png_ptr->dither_index[i] = (png_byte)min_k; in png_set_dither()
305 png_free(png_ptr, png_ptr->dither_sort); in png_set_dither()
306 png_ptr->dither_sort = NULL; in png_set_dither()
327 png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, in png_set_dither()
329 png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, in png_set_dither()
335 png_ptr->index_to_palette[i] = (png_byte)i; in png_set_dither()
336 png_ptr->palette_to_index[i] = (png_byte)i; in png_set_dither()
339 hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 * in png_set_dither()
369 t = (png_dsortp)png_malloc_warn(png_ptr, in png_set_dither()
392 if ((int)png_ptr->index_to_palette[p->left] in png_set_dither()
394 (int)png_ptr->index_to_palette[p->right] in png_set_dither()
411 palette[png_ptr->index_to_palette[j]] in png_set_dither()
419 if (png_ptr->dither_index[k] == in png_set_dither()
420 png_ptr->index_to_palette[j]) in png_set_dither()
421 png_ptr->dither_index[k] = in png_set_dither()
422 png_ptr->index_to_palette[next_j]; in png_set_dither()
423 if ((int)png_ptr->dither_index[k] == in png_set_dither()
425 png_ptr->dither_index[k] = in png_set_dither()
426 png_ptr->index_to_palette[j]; in png_set_dither()
430 png_ptr->index_to_palette[png_ptr->palette_to_index in png_set_dither()
431 [num_new_palette]] = png_ptr->index_to_palette[j]; in png_set_dither()
432 png_ptr->palette_to_index[png_ptr->index_to_palette[j]] in png_set_dither()
433 = png_ptr->palette_to_index[num_new_palette]; in png_set_dither()
435 png_ptr->index_to_palette[j] = in png_set_dither()
437 png_ptr->palette_to_index[num_new_palette] = in png_set_dither()
456 png_free(png_ptr, p); in png_set_dither()
464 png_free(png_ptr, hash); in png_set_dither()
465 png_free(png_ptr, png_ptr->palette_to_index); in png_set_dither()
466 png_free(png_ptr, png_ptr->index_to_palette); in png_set_dither()
467 png_ptr->palette_to_index = NULL; in png_set_dither()
468 png_ptr->index_to_palette = NULL; in png_set_dither()
472 if (png_ptr->palette == NULL) in png_set_dither()
474 png_ptr->palette = palette; in png_set_dither()
476 png_ptr->num_palette = (png_uint_16)num_palette; in png_set_dither()
489 png_ptr->palette_lookup = (png_bytep )png_calloc(png_ptr, in png_set_dither()
492 distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * in png_set_dither()
529 png_ptr->palette_lookup[d_index] = (png_byte)i; in png_set_dither()
536 png_free(png_ptr, distance); in png_set_dither()
552 png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) in png_set_gamma() argument
556 if (png_ptr == NULL) in png_set_gamma()
560 (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || in png_set_gamma()
561 (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) in png_set_gamma()
562 png_ptr->transformations |= PNG_GAMMA; in png_set_gamma()
563 png_ptr->gamma = (float)file_gamma; in png_set_gamma()
564 png_ptr->screen_gamma = (float)scrn_gamma; in png_set_gamma()
574 png_set_expand(png_structp png_ptr) in png_set_expand() argument
578 if (png_ptr == NULL) in png_set_expand()
581 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_expand()
582 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_expand()
605 png_set_palette_to_rgb(png_structp png_ptr) in png_set_palette_to_rgb() argument
609 if (png_ptr == NULL) in png_set_palette_to_rgb()
612 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_palette_to_rgb()
613 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_palette_to_rgb()
619 png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) in png_set_expand_gray_1_2_4_to_8() argument
623 if (png_ptr == NULL) in png_set_expand_gray_1_2_4_to_8()
626 png_ptr->transformations |= PNG_EXPAND; in png_set_expand_gray_1_2_4_to_8()
627 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_expand_gray_1_2_4_to_8()
635 png_set_gray_1_2_4_to_8(png_structp png_ptr) in png_set_gray_1_2_4_to_8() argument
639 if (png_ptr == NULL) in png_set_gray_1_2_4_to_8()
642 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_gray_1_2_4_to_8()
649 png_set_tRNS_to_alpha(png_structp png_ptr) in png_set_tRNS_to_alpha() argument
653 png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); in png_set_tRNS_to_alpha()
654 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_tRNS_to_alpha()
660 png_set_gray_to_rgb(png_structp png_ptr) in png_set_gray_to_rgb() argument
664 png_ptr->transformations |= PNG_GRAY_TO_RGB; in png_set_gray_to_rgb()
665 png_ptr->flags &= ~PNG_FLAG_ROW_INIT; in png_set_gray_to_rgb()
676 png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, in png_set_rgb_to_gray() argument
680 if (png_ptr == NULL) in png_set_rgb_to_gray()
685 png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); in png_set_rgb_to_gray()
694 png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); in png_set_rgb_to_gray()
699 png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, in png_set_rgb_to_gray_fixed() argument
704 if (png_ptr == NULL) in png_set_rgb_to_gray_fixed()
709 case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; in png_set_rgb_to_gray_fixed()
712 case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; in png_set_rgb_to_gray_fixed()
715 case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; in png_set_rgb_to_gray_fixed()
717 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_set_rgb_to_gray_fixed()
719 png_ptr->transformations |= PNG_EXPAND; in png_set_rgb_to_gray_fixed()
722 png_warning(png_ptr, in png_set_rgb_to_gray_fixed()
724 png_ptr->transformations &= ~PNG_RGB_TO_GRAY; in png_set_rgb_to_gray_fixed()
741 png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients"); in png_set_rgb_to_gray_fixed()
745 png_ptr->rgb_to_gray_red_coeff = red_int; in png_set_rgb_to_gray_fixed()
746 png_ptr->rgb_to_gray_green_coeff = green_int; in png_set_rgb_to_gray_fixed()
747 png_ptr->rgb_to_gray_blue_coeff = in png_set_rgb_to_gray_fixed()
757 png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr in png_set_read_user_transform_fn() argument
762 if (png_ptr == NULL) in png_set_read_user_transform_fn()
766 png_ptr->transformations |= PNG_USER_TRANSFORM; in png_set_read_user_transform_fn()
767 png_ptr->read_user_transform_fn = read_user_transform_fn; in png_set_read_user_transform_fn()
771 png_warning(png_ptr, in png_set_read_user_transform_fn()
781 png_init_read_transformations(png_structp png_ptr) in png_init_read_transformations() argument
786 if (png_ptr != NULL) in png_init_read_transformations()
792 int color_type = png_ptr->color_type; in png_init_read_transformations()
808 if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && in png_init_read_transformations()
811 png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; in png_init_read_transformations()
812 } else if ((png_ptr->transformations & PNG_BACKGROUND) && in png_init_read_transformations()
813 !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) && in png_init_read_transformations()
814 (png_ptr->transformations & PNG_GRAY_TO_RGB) && in png_init_read_transformations()
815 png_ptr->background.red == png_ptr->background.green && in png_init_read_transformations()
816 png_ptr->background.red == png_ptr->background.blue) in png_init_read_transformations()
818 png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; in png_init_read_transformations()
819 png_ptr->background.gray = png_ptr->background.red; in png_init_read_transformations()
823 if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) && in png_init_read_transformations()
824 (png_ptr->transformations & PNG_EXPAND)) in png_init_read_transformations()
829 switch (png_ptr->bit_depth) in png_init_read_transformations()
832 png_ptr->background.gray *= (png_uint_16)0xff; in png_init_read_transformations()
833 png_ptr->background.red = png_ptr->background.green in png_init_read_transformations()
834 = png_ptr->background.blue = png_ptr->background.gray; in png_init_read_transformations()
835 if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) in png_init_read_transformations()
837 png_ptr->trans_values.gray *= (png_uint_16)0xff; in png_init_read_transformations()
838 png_ptr->trans_values.red = png_ptr->trans_values.green in png_init_read_transformations()
839 = png_ptr->trans_values.blue = png_ptr->trans_values.gray; in png_init_read_transformations()
844 png_ptr->background.gray *= (png_uint_16)0x55; in png_init_read_transformations()
845 png_ptr->background.red = png_ptr->background.green in png_init_read_transformations()
846 = png_ptr->background.blue = png_ptr->background.gray; in png_init_read_transformations()
847 if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) in png_init_read_transformations()
849 png_ptr->trans_values.gray *= (png_uint_16)0x55; in png_init_read_transformations()
850 png_ptr->trans_values.red = png_ptr->trans_values.green in png_init_read_transformations()
851 = png_ptr->trans_values.blue = png_ptr->trans_values.gray; in png_init_read_transformations()
856 png_ptr->background.gray *= (png_uint_16)0x11; in png_init_read_transformations()
857 png_ptr->background.red = png_ptr->background.green in png_init_read_transformations()
858 = png_ptr->background.blue = png_ptr->background.gray; in png_init_read_transformations()
859 if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) in png_init_read_transformations()
861 png_ptr->trans_values.gray *= (png_uint_16)0x11; in png_init_read_transformations()
862 png_ptr->trans_values.red = png_ptr->trans_values.green in png_init_read_transformations()
863 = png_ptr->trans_values.blue = png_ptr->trans_values.gray; in png_init_read_transformations()
870 png_ptr->background.red = png_ptr->background.green in png_init_read_transformations()
871 = png_ptr->background.blue = png_ptr->background.gray; in png_init_read_transformations()
877 png_ptr->background.red = in png_init_read_transformations()
878 png_ptr->palette[png_ptr->background.index].red; in png_init_read_transformations()
879 png_ptr->background.green = in png_init_read_transformations()
880 png_ptr->palette[png_ptr->background.index].green; in png_init_read_transformations()
881 png_ptr->background.blue = in png_init_read_transformations()
882 png_ptr->palette[png_ptr->background.index].blue; in png_init_read_transformations()
885 if (png_ptr->transformations & PNG_INVERT_ALPHA) in png_init_read_transformations()
888 if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) in png_init_read_transformations()
895 istop=(int)png_ptr->num_trans; in png_init_read_transformations()
897 png_ptr->trans[i] = (png_byte)(255 - png_ptr->trans[i]); in png_init_read_transformations()
907 png_ptr->background_1 = png_ptr->background; in png_init_read_transformations()
911 if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0) in png_init_read_transformations()
912 && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) in png_init_read_transformations()
917 for (i=0; i<png_ptr->num_trans; i++) in png_init_read_transformations()
919 if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) in png_init_read_transformations()
923 png_ptr->transformations &= ~PNG_GAMMA; in png_init_read_transformations()
926 if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) && in png_init_read_transformations()
927 png_ptr->gamma != 0.0) in png_init_read_transformations()
929 png_build_gamma_table(png_ptr); in png_init_read_transformations()
932 if (png_ptr->transformations & PNG_BACKGROUND) in png_init_read_transformations()
938 png_colorp palette = png_ptr->palette; in png_init_read_transformations()
939 int num_palette = png_ptr->num_palette; in png_init_read_transformations()
941 if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) in png_init_read_transformations()
943 back.red = png_ptr->gamma_table[png_ptr->background.red]; in png_init_read_transformations()
944 back.green = png_ptr->gamma_table[png_ptr->background.green]; in png_init_read_transformations()
945 back.blue = png_ptr->gamma_table[png_ptr->background.blue]; in png_init_read_transformations()
947 back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; in png_init_read_transformations()
948 back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; in png_init_read_transformations()
949 back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; in png_init_read_transformations()
955 switch (png_ptr->background_gamma_type) in png_init_read_transformations()
958 g = (png_ptr->screen_gamma); in png_init_read_transformations()
963 g = 1.0 / (png_ptr->gamma); in png_init_read_transformations()
964 gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); in png_init_read_transformations()
968 g = 1.0 / (png_ptr->background_gamma); in png_init_read_transformations()
969 gs = 1.0 / (png_ptr->background_gamma * in png_init_read_transformations()
970 png_ptr->screen_gamma); in png_init_read_transformations()
979 back.red = (png_byte)png_ptr->background.red; in png_init_read_transformations()
980 back.green = (png_byte)png_ptr->background.green; in png_init_read_transformations()
981 back.blue = (png_byte)png_ptr->background.blue; in png_init_read_transformations()
986 (double)png_ptr->background.red/255, gs) * 255.0 + .5); in png_init_read_transformations()
988 (double)png_ptr->background.green/255, gs) * 255.0 in png_init_read_transformations()
991 (double)png_ptr->background.blue/255, gs) * 255.0 + .5); in png_init_read_transformations()
995 (double)png_ptr->background.red/255, g) * 255.0 + .5); in png_init_read_transformations()
997 (double)png_ptr->background.green/255, g) * 255.0 + .5); in png_init_read_transformations()
999 (double)png_ptr->background.blue/255, g) * 255.0 + .5); in png_init_read_transformations()
1003 if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff) in png_init_read_transformations()
1005 if (png_ptr->trans[i] == 0) in png_init_read_transformations()
1013 v = png_ptr->gamma_to_1[palette[i].red]; in png_init_read_transformations()
1014 png_composite(w, v, png_ptr->trans[i], back_1.red); in png_init_read_transformations()
1015 palette[i].red = png_ptr->gamma_from_1[w]; in png_init_read_transformations()
1017 v = png_ptr->gamma_to_1[palette[i].green]; in png_init_read_transformations()
1018 png_composite(w, v, png_ptr->trans[i], back_1.green); in png_init_read_transformations()
1019 palette[i].green = png_ptr->gamma_from_1[w]; in png_init_read_transformations()
1021 v = png_ptr->gamma_to_1[palette[i].blue]; in png_init_read_transformations()
1022 png_composite(w, v, png_ptr->trans[i], back_1.blue); in png_init_read_transformations()
1023 palette[i].blue = png_ptr->gamma_from_1[w]; in png_init_read_transformations()
1028 palette[i].red = png_ptr->gamma_table[palette[i].red]; in png_init_read_transformations()
1029 palette[i].green = png_ptr->gamma_table[palette[i].green]; in png_init_read_transformations()
1030 palette[i].blue = png_ptr->gamma_table[palette[i].blue]; in png_init_read_transformations()
1038 png_ptr->transformations &= ~PNG_BACKGROUND; in png_init_read_transformations()
1039 png_ptr->transformations &= ~PNG_GAMMA; in png_init_read_transformations()
1040 png_ptr->transformations |= PNG_STRIP_ALPHA; in png_init_read_transformations()
1046 double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1); in png_init_read_transformations()
1050 switch (png_ptr->background_gamma_type) in png_init_read_transformations()
1053 g = (png_ptr->screen_gamma); in png_init_read_transformations()
1058 g = 1.0 / (png_ptr->gamma); in png_init_read_transformations()
1059 gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); in png_init_read_transformations()
1063 g = 1.0 / (png_ptr->background_gamma); in png_init_read_transformations()
1064 gs = 1.0 / (png_ptr->background_gamma * in png_init_read_transformations()
1065 png_ptr->screen_gamma); in png_init_read_transformations()
1069 png_ptr->background_1.gray = (png_uint_16)(pow( in png_init_read_transformations()
1070 (double)png_ptr->background.gray / m, g) * m + .5); in png_init_read_transformations()
1071 png_ptr->background.gray = (png_uint_16)(pow( in png_init_read_transformations()
1072 (double)png_ptr->background.gray / m, gs) * m + .5); in png_init_read_transformations()
1074 if ((png_ptr->background.red != png_ptr->background.green) || in png_init_read_transformations()
1075 (png_ptr->background.red != png_ptr->background.blue) || in png_init_read_transformations()
1076 (png_ptr->background.red != png_ptr->background.gray)) in png_init_read_transformations()
1079 png_ptr->background_1.red = (png_uint_16)(pow( in png_init_read_transformations()
1080 (double)png_ptr->background.red / m, g) * m + .5); in png_init_read_transformations()
1081 png_ptr->background_1.green = (png_uint_16)(pow( in png_init_read_transformations()
1082 (double)png_ptr->background.green / m, g) * m + .5); in png_init_read_transformations()
1083 png_ptr->background_1.blue = (png_uint_16)(pow( in png_init_read_transformations()
1084 (double)png_ptr->background.blue / m, g) * m + .5); in png_init_read_transformations()
1085 png_ptr->background.red = (png_uint_16)(pow( in png_init_read_transformations()
1086 (double)png_ptr->background.red / m, gs) * m + .5); in png_init_read_transformations()
1087 png_ptr->background.green = (png_uint_16)(pow( in png_init_read_transformations()
1088 (double)png_ptr->background.green / m, gs) * m + .5); in png_init_read_transformations()
1089 png_ptr->background.blue = (png_uint_16)(pow( in png_init_read_transformations()
1090 (double)png_ptr->background.blue / m, gs) * m + .5); in png_init_read_transformations()
1095 png_ptr->background_1.red = png_ptr->background_1.green in png_init_read_transformations()
1096 = png_ptr->background_1.blue = png_ptr->background_1.gray; in png_init_read_transformations()
1097 png_ptr->background.red = png_ptr->background.green in png_init_read_transformations()
1098 = png_ptr->background.blue = png_ptr->background.gray; in png_init_read_transformations()
1107 png_colorp palette = png_ptr->palette; in png_init_read_transformations()
1108 int num_palette = png_ptr->num_palette; in png_init_read_transformations()
1113 palette[i].red = png_ptr->gamma_table[palette[i].red]; in png_init_read_transformations()
1114 palette[i].green = png_ptr->gamma_table[palette[i].green]; in png_init_read_transformations()
1115 palette[i].blue = png_ptr->gamma_table[palette[i].blue]; in png_init_read_transformations()
1119 png_ptr->transformations &= ~PNG_GAMMA; in png_init_read_transformations()
1128 if ((png_ptr->transformations & PNG_BACKGROUND) && in png_init_read_transformations()
1132 int istop = (int)png_ptr->num_trans; in png_init_read_transformations()
1134 png_colorp palette = png_ptr->palette; in png_init_read_transformations()
1136 back.red = (png_byte)png_ptr->background.red; in png_init_read_transformations()
1137 back.green = (png_byte)png_ptr->background.green; in png_init_read_transformations()
1138 back.blue = (png_byte)png_ptr->background.blue; in png_init_read_transformations()
1142 if (png_ptr->trans[i] == 0) in png_init_read_transformations()
1146 else if (png_ptr->trans[i] != 0xff) in png_init_read_transformations()
1150 png_ptr->trans[i], back.red); in png_init_read_transformations()
1152 png_ptr->trans[i], back.green); in png_init_read_transformations()
1154 png_ptr->trans[i], back.blue); in png_init_read_transformations()
1159 png_ptr->transformations &= ~PNG_BACKGROUND; in png_init_read_transformations()
1160 png_ptr->transformations |= PNG_STRIP_ALPHA; in png_init_read_transformations()
1165 if ((png_ptr->transformations & PNG_SHIFT) && in png_init_read_transformations()
1169 png_uint_16 istop = png_ptr->num_palette; in png_init_read_transformations()
1170 int sr = 8 - png_ptr->sig_bit.red; in png_init_read_transformations()
1171 int sg = 8 - png_ptr->sig_bit.green; in png_init_read_transformations()
1172 int sb = 8 - png_ptr->sig_bit.blue; in png_init_read_transformations()
1182 png_ptr->palette[i].red >>= sr; in png_init_read_transformations()
1183 png_ptr->palette[i].green >>= sg; in png_init_read_transformations()
1184 png_ptr->palette[i].blue >>= sb; in png_init_read_transformations()
1191 if (png_ptr) in png_init_read_transformations()
1201 png_read_transform_info(png_structp png_ptr, png_infop info_ptr) in png_read_transform_info() argument
1206 if (png_ptr->transformations & PNG_EXPAND) in png_read_transform_info()
1210 if (png_ptr->num_trans) in png_read_transform_info()
1219 if (png_ptr->num_trans) in png_read_transform_info()
1221 if (png_ptr->transformations & PNG_EXPAND_tRNS) in png_read_transform_info()
1232 if (png_ptr->transformations & PNG_BACKGROUND) in png_read_transform_info()
1236 info_ptr->background = png_ptr->background; in png_read_transform_info()
1241 if (png_ptr->transformations & PNG_GAMMA) in png_read_transform_info()
1244 info_ptr->gamma = png_ptr->gamma; in png_read_transform_info()
1247 info_ptr->int_gamma = png_ptr->int_gamma; in png_read_transform_info()
1253 if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16)) in png_read_transform_info()
1258 if (png_ptr->transformations & PNG_GRAY_TO_RGB) in png_read_transform_info()
1263 if (png_ptr->transformations & PNG_RGB_TO_GRAY) in png_read_transform_info()
1268 if (png_ptr->transformations & PNG_DITHER) in png_read_transform_info()
1272 png_ptr->palette_lookup && info_ptr->bit_depth == 8) in png_read_transform_info()
1280 if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8)) in png_read_transform_info()
1292 if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) in png_read_transform_info()
1301 if ((png_ptr->transformations & PNG_FILLER) && in png_read_transform_info()
1308 if (png_ptr->transformations & PNG_ADD_ALPHA) in png_read_transform_info()
1316 if (png_ptr->transformations & PNG_USER_TRANSFORM) in png_read_transform_info()
1318 if (info_ptr->bit_depth < png_ptr->user_transform_depth) in png_read_transform_info()
1319 info_ptr->bit_depth = png_ptr->user_transform_depth; in png_read_transform_info()
1320 if (info_ptr->channels < png_ptr->user_transform_channels) in png_read_transform_info()
1321 info_ptr->channels = png_ptr->user_transform_channels; in png_read_transform_info()
1331 if (png_ptr) in png_read_transform_info()
1341 png_do_read_transformations(png_structp png_ptr) in png_do_read_transformations() argument
1345 if (png_ptr->row_buf == NULL) in png_do_read_transformations()
1351 "NULL row buffer for row %ld, pass %d", (long)png_ptr->row_number, in png_do_read_transformations()
1352 png_ptr->pass); in png_do_read_transformations()
1353 png_error(png_ptr, msg); in png_do_read_transformations()
1355 png_error(png_ptr, "NULL row buffer"); in png_do_read_transformations()
1359 if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) in png_do_read_transformations()
1365 png_error(png_ptr, "Uninitialized row"); in png_do_read_transformations()
1367 png_warning(png_ptr, "Uninitialized row"); in png_do_read_transformations()
1372 if (png_ptr->transformations & PNG_EXPAND) in png_do_read_transformations()
1374 if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE) in png_do_read_transformations()
1376 png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1, in png_do_read_transformations()
1377 png_ptr->palette, png_ptr->trans, png_ptr->num_trans); in png_do_read_transformations()
1381 if (png_ptr->num_trans && in png_do_read_transformations()
1382 (png_ptr->transformations & PNG_EXPAND_tRNS)) in png_do_read_transformations()
1383 png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, in png_do_read_transformations()
1384 &(png_ptr->trans_values)); in png_do_read_transformations()
1386 png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1, in png_do_read_transformations()
1393 if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA) in png_do_read_transformations()
1394 png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, in png_do_read_transformations()
1395 PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)); in png_do_read_transformations()
1399 if (png_ptr->transformations & PNG_RGB_TO_GRAY) in png_do_read_transformations()
1402 png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), in png_do_read_transformations()
1403 png_ptr->row_buf + 1); in png_do_read_transformations()
1406 png_ptr->rgb_to_gray_status=1; in png_do_read_transformations()
1407 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == in png_do_read_transformations()
1409 png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); in png_do_read_transformations()
1410 if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == in png_do_read_transformations()
1412 png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); in png_do_read_transformations()
1452 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && in png_do_read_transformations()
1453 !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) in png_do_read_transformations()
1454 png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1458 if ((png_ptr->transformations & PNG_BACKGROUND) && in png_do_read_transformations()
1459 ((png_ptr->num_trans != 0 ) || in png_do_read_transformations()
1460 (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) in png_do_read_transformations()
1461 png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1, in png_do_read_transformations()
1462 &(png_ptr->trans_values), &(png_ptr->background) in png_do_read_transformations()
1464 , &(png_ptr->background_1), in png_do_read_transformations()
1465 png_ptr->gamma_table, png_ptr->gamma_from_1, in png_do_read_transformations()
1466 png_ptr->gamma_to_1, png_ptr->gamma_16_table, in png_do_read_transformations()
1467 png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1, in png_do_read_transformations()
1468 png_ptr->gamma_shift in png_do_read_transformations()
1474 if ((png_ptr->transformations & PNG_GAMMA) && in png_do_read_transformations()
1476 !((png_ptr->transformations & PNG_BACKGROUND) && in png_do_read_transformations()
1477 ((png_ptr->num_trans != 0) || in png_do_read_transformations()
1478 (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && in png_do_read_transformations()
1480 (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) in png_do_read_transformations()
1481 png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, in png_do_read_transformations()
1482 png_ptr->gamma_table, png_ptr->gamma_16_table, in png_do_read_transformations()
1483 png_ptr->gamma_shift); in png_do_read_transformations()
1487 if (png_ptr->transformations & PNG_16_TO_8) in png_do_read_transformations()
1488 png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1492 if (png_ptr->transformations & PNG_DITHER) in png_do_read_transformations()
1494 png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, in png_do_read_transformations()
1495 png_ptr->palette_lookup, png_ptr->dither_index); in png_do_read_transformations()
1496 if (png_ptr->row_info.rowbytes == (png_uint_32)0) in png_do_read_transformations()
1497 png_error(png_ptr, "png_do_dither returned rowbytes=0"); in png_do_read_transformations()
1502 if (png_ptr->transformations & PNG_INVERT_MONO) in png_do_read_transformations()
1503 png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1507 if (png_ptr->transformations & PNG_SHIFT) in png_do_read_transformations()
1508 png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1, in png_do_read_transformations()
1509 &(png_ptr->shift)); in png_do_read_transformations()
1513 if (png_ptr->transformations & PNG_PACK) in png_do_read_transformations()
1514 png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1518 if (png_ptr->transformations & PNG_BGR) in png_do_read_transformations()
1519 png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1523 if (png_ptr->transformations & PNG_PACKSWAP) in png_do_read_transformations()
1524 png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1529 if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && in png_do_read_transformations()
1530 (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) in png_do_read_transformations()
1531 png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1535 if (png_ptr->transformations & PNG_FILLER) in png_do_read_transformations()
1536 png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1, in png_do_read_transformations()
1537 (png_uint_32)png_ptr->filler, png_ptr->flags); in png_do_read_transformations()
1541 if (png_ptr->transformations & PNG_INVERT_ALPHA) in png_do_read_transformations()
1542 png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1546 if (png_ptr->transformations & PNG_SWAP_ALPHA) in png_do_read_transformations()
1547 png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1551 if (png_ptr->transformations & PNG_SWAP_BYTES) in png_do_read_transformations()
1552 png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1); in png_do_read_transformations()
1556 if (png_ptr->transformations & PNG_USER_TRANSFORM) in png_do_read_transformations()
1558 if (png_ptr->read_user_transform_fn != NULL) in png_do_read_transformations()
1559 (*(png_ptr->read_user_transform_fn)) /* User read transform function */ in png_do_read_transformations()
1560 (png_ptr, /* png_ptr */ in png_do_read_transformations()
1561 &(png_ptr->row_info), /* row_info: */ in png_do_read_transformations()
1568 png_ptr->row_buf + 1); /* start of pixel data for row */ in png_do_read_transformations()
1570 if (png_ptr->user_transform_depth) in png_do_read_transformations()
1571 png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; in png_do_read_transformations()
1572 if (png_ptr->user_transform_channels) in png_do_read_transformations()
1573 png_ptr->row_info.channels = png_ptr->user_transform_channels; in png_do_read_transformations()
1575 png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * in png_do_read_transformations()
1576 png_ptr->row_info.channels); in png_do_read_transformations()
1577 png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, in png_do_read_transformations()
1578 png_ptr->row_info.width); in png_do_read_transformations()
2327 png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) in png_do_rgb_to_gray() argument
2343 png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; in png_do_rgb_to_gray()
2344 png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; in png_do_rgb_to_gray()
2345 png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff; in png_do_rgb_to_gray()
2352 if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) in png_do_rgb_to_gray()
2359 png_byte red = png_ptr->gamma_to_1[*(sp++)]; in png_do_rgb_to_gray()
2360 png_byte green = png_ptr->gamma_to_1[*(sp++)]; in png_do_rgb_to_gray()
2361 png_byte blue = png_ptr->gamma_to_1[*(sp++)]; in png_do_rgb_to_gray()
2365 *(dp++) = png_ptr->gamma_from_1[ in png_do_rgb_to_gray()
2396 if (png_ptr->gamma_16_to_1 != NULL && in png_do_rgb_to_gray()
2397 png_ptr->gamma_16_from_1 != NULL) in png_do_rgb_to_gray()
2413 png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> in png_do_rgb_to_gray()
2414 png_ptr->gamma_shift][red>>8]; in png_do_rgb_to_gray()
2416 png_ptr->gamma_16_to_1[(green&0xff) >> in png_do_rgb_to_gray()
2417 png_ptr->gamma_shift][green>>8]; in png_do_rgb_to_gray()
2418 png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> in png_do_rgb_to_gray()
2419 png_ptr->gamma_shift][blue>>8]; in png_do_rgb_to_gray()
2422 w = png_ptr->gamma_16_from_1[(gray16&0xff) >> in png_do_rgb_to_gray()
2423 png_ptr->gamma_shift][gray16 >> 8]; in png_do_rgb_to_gray()
2458 if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) in png_do_rgb_to_gray()
2464 png_byte red = png_ptr->gamma_to_1[*(sp++)]; in png_do_rgb_to_gray()
2465 png_byte green = png_ptr->gamma_to_1[*(sp++)]; in png_do_rgb_to_gray()
2466 png_byte blue = png_ptr->gamma_to_1[*(sp++)]; in png_do_rgb_to_gray()
2469 *(dp++) = png_ptr->gamma_from_1 in png_do_rgb_to_gray()
2494 if (png_ptr->gamma_16_to_1 != NULL && in png_do_rgb_to_gray()
2495 png_ptr->gamma_16_from_1 != NULL) in png_do_rgb_to_gray()
2511 png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >> in png_do_rgb_to_gray()
2512 png_ptr->gamma_shift][red>>8]; in png_do_rgb_to_gray()
2514 png_ptr->gamma_16_to_1[(green&0xff) >> in png_do_rgb_to_gray()
2515 png_ptr->gamma_shift][green>>8]; in png_do_rgb_to_gray()
2516 png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >> in png_do_rgb_to_gray()
2517 png_ptr->gamma_shift][blue>>8]; in png_do_rgb_to_gray()
2520 w = png_ptr->gamma_16_from_1[(gray16&0xff) >> in png_do_rgb_to_gray()
2521 png_ptr->gamma_shift][gray16 >> 8]; in png_do_rgb_to_gray()
2621 png_correct_palette(png_structp png_ptr, png_colorp palette, in png_correct_palette() argument
2629 if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) in png_correct_palette()
2633 if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) in png_correct_palette()
2635 back.red = png_ptr->gamma_table[png_ptr->background.red]; in png_correct_palette()
2636 back.green = png_ptr->gamma_table[png_ptr->background.green]; in png_correct_palette()
2637 back.blue = png_ptr->gamma_table[png_ptr->background.blue]; in png_correct_palette()
2639 back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; in png_correct_palette()
2640 back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; in png_correct_palette()
2641 back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; in png_correct_palette()
2647 g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma); in png_correct_palette()
2649 if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN in png_correct_palette()
2652 back.red = png_ptr->background.red; in png_correct_palette()
2653 back.green = png_ptr->background.green; in png_correct_palette()
2654 back.blue = png_ptr->background.blue; in png_correct_palette()
2659 (png_byte)(pow((double)png_ptr->background.red/255, g) * in png_correct_palette()
2662 (png_byte)(pow((double)png_ptr->background.green/255, g) * in png_correct_palette()
2665 (png_byte)(pow((double)png_ptr->background.blue/255, g) * in png_correct_palette()
2669 g = 1.0 / png_ptr->background_gamma; in png_correct_palette()
2672 (png_byte)(pow((double)png_ptr->background.red/255, g) * in png_correct_palette()
2675 (png_byte)(pow((double)png_ptr->background.green/255, g) * in png_correct_palette()
2678 (png_byte)(pow((double)png_ptr->background.blue/255, g) * in png_correct_palette()
2682 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_correct_palette()
2688 if (i < png_ptr->num_trans && png_ptr->trans[i] == 0) in png_correct_palette()
2692 else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff) in png_correct_palette()
2696 v = png_ptr->gamma_to_1[png_ptr->palette[i].red]; in png_correct_palette()
2697 png_composite(w, v, png_ptr->trans[i], back_1.red); in png_correct_palette()
2698 palette[i].red = png_ptr->gamma_from_1[w]; in png_correct_palette()
2700 v = png_ptr->gamma_to_1[png_ptr->palette[i].green]; in png_correct_palette()
2701 png_composite(w, v, png_ptr->trans[i], back_1.green); in png_correct_palette()
2702 palette[i].green = png_ptr->gamma_from_1[w]; in png_correct_palette()
2704 v = png_ptr->gamma_to_1[png_ptr->palette[i].blue]; in png_correct_palette()
2705 png_composite(w, v, png_ptr->trans[i], back_1.blue); in png_correct_palette()
2706 palette[i].blue = png_ptr->gamma_from_1[w]; in png_correct_palette()
2710 palette[i].red = png_ptr->gamma_table[palette[i].red]; in png_correct_palette()
2711 palette[i].green = png_ptr->gamma_table[palette[i].green]; in png_correct_palette()
2712 palette[i].blue = png_ptr->gamma_table[palette[i].blue]; in png_correct_palette()
2722 if (palette[i].red == (png_byte)png_ptr->trans_values.gray) in png_correct_palette()
2728 palette[i].red = png_ptr->gamma_table[palette[i].red]; in png_correct_palette()
2729 palette[i].green = png_ptr->gamma_table[palette[i].green]; in png_correct_palette()
2730 palette[i].blue = png_ptr->gamma_table[palette[i].blue]; in png_correct_palette()
2738 if (png_ptr->transformations & PNG_GAMMA) in png_correct_palette()
2744 palette[i].red = png_ptr->gamma_table[palette[i].red]; in png_correct_palette()
2745 palette[i].green = png_ptr->gamma_table[palette[i].green]; in png_correct_palette()
2746 palette[i].blue = png_ptr->gamma_table[palette[i].blue]; in png_correct_palette()
2754 if (png_ptr->transformations & PNG_BACKGROUND) in png_correct_palette()
2756 if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) in png_correct_palette()
2760 back.red = (png_byte)png_ptr->background.red; in png_correct_palette()
2761 back.green = (png_byte)png_ptr->background.green; in png_correct_palette()
2762 back.blue = (png_byte)png_ptr->background.blue; in png_correct_palette()
2764 for (i = 0; i < (int)png_ptr->num_trans; i++) in png_correct_palette()
2766 if (png_ptr->trans[i] == 0) in png_correct_palette()
2772 else if (png_ptr->trans[i] != 0xff) in png_correct_palette()
2774 png_composite(palette[i].red, png_ptr->palette[i].red, in png_correct_palette()
2775 png_ptr->trans[i], back.red); in png_correct_palette()
2776 png_composite(palette[i].green, png_ptr->palette[i].green, in png_correct_palette()
2777 png_ptr->trans[i], back.green); in png_correct_palette()
2778 png_composite(palette[i].blue, png_ptr->palette[i].blue, in png_correct_palette()
2779 png_ptr->trans[i], back.blue); in png_correct_palette()
2789 if (i == (png_byte)png_ptr->trans_values.gray) in png_correct_palette()
2791 palette[i].red = (png_byte)png_ptr->background.red; in png_correct_palette()
2792 palette[i].green = (png_byte)png_ptr->background.green; in png_correct_palette()
2793 palette[i].blue = (png_byte)png_ptr->background.blue; in png_correct_palette()
4183 png_build_gamma_table(png_structp png_ptr) in png_build_gamma_table() argument
4187 if (png_ptr->bit_depth <= 8) in png_build_gamma_table()
4192 if (png_ptr->screen_gamma > .000001) in png_build_gamma_table()
4193 g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); in png_build_gamma_table()
4198 png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr, in png_build_gamma_table()
4203 png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0, in png_build_gamma_table()
4209 if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY)) in png_build_gamma_table()
4212 g = 1.0 / (png_ptr->gamma); in png_build_gamma_table()
4214 png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr, in png_build_gamma_table()
4219 png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0, in png_build_gamma_table()
4224 png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, in png_build_gamma_table()
4227 if (png_ptr->screen_gamma > 0.000001) in png_build_gamma_table()
4228 g = 1.0 / png_ptr->screen_gamma; in png_build_gamma_table()
4231 g = png_ptr->gamma; /* Probably doing rgb_to_gray */ in png_build_gamma_table()
4235 png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0, in png_build_gamma_table()
4249 if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) in png_build_gamma_table()
4251 sig_bit = (int)png_ptr->sig_bit.red; in png_build_gamma_table()
4253 if ((int)png_ptr->sig_bit.green > sig_bit) in png_build_gamma_table()
4254 sig_bit = png_ptr->sig_bit.green; in png_build_gamma_table()
4256 if ((int)png_ptr->sig_bit.blue > sig_bit) in png_build_gamma_table()
4257 sig_bit = png_ptr->sig_bit.blue; in png_build_gamma_table()
4261 sig_bit = (int)png_ptr->sig_bit.gray; in png_build_gamma_table()
4270 if (png_ptr->transformations & PNG_16_TO_8) in png_build_gamma_table()
4282 png_ptr->gamma_shift = (png_byte)shift; in png_build_gamma_table()
4286 if (png_ptr->screen_gamma > .000001) in png_build_gamma_table()
4287 g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); in png_build_gamma_table()
4291 png_ptr->gamma_16_table = (png_uint_16pp)png_calloc(png_ptr, in png_build_gamma_table()
4294 if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) in png_build_gamma_table()
4301 png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, in png_build_gamma_table()
4314 png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] in png_build_gamma_table()
4322 png_ptr->gamma_16_table[(int)(last & (0xff >> shift))] in png_build_gamma_table()
4331 png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, in png_build_gamma_table()
4338 png_ptr->gamma_16_table[i][j] = in png_build_gamma_table()
4347 if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY)) in png_build_gamma_table()
4350 g = 1.0 / (png_ptr->gamma); in png_build_gamma_table()
4352 png_ptr->gamma_16_to_1 = (png_uint_16pp)png_calloc(png_ptr, in png_build_gamma_table()
4357 png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, in png_build_gamma_table()
4364 png_ptr->gamma_16_to_1[i][j] = in png_build_gamma_table()
4370 if (png_ptr->screen_gamma > 0.000001) in png_build_gamma_table()
4371 g = 1.0 / png_ptr->screen_gamma; in png_build_gamma_table()
4374 g = png_ptr->gamma; /* Probably doing rgb_to_gray */ in png_build_gamma_table()
4376 png_ptr->gamma_16_from_1 = (png_uint_16pp)png_calloc(png_ptr, in png_build_gamma_table()
4381 png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, in png_build_gamma_table()
4389 png_ptr->gamma_16_from_1[i][j] = in png_build_gamma_table()