Prusa MINI Firmware overview
|
|
void PNGAPI | png_set_crc_action (png_structrp png_ptr, int crit_action, int ancil_action) |
|
static int | png_rtran_ok (png_structrp png_ptr, int need_IHDR) |
|
void PNGFAPI | png_set_background_fixed (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma) |
|
void PNGAPI | png_set_background (png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma) |
|
void PNGAPI | png_set_scale_16 (png_structrp png_ptr) |
|
void PNGAPI | png_set_strip_16 (png_structrp png_ptr) |
|
void PNGAPI | png_set_strip_alpha (png_structrp png_ptr) |
|
static png_fixed_point | translate_gamma_flags (png_structrp png_ptr, png_fixed_point output_gamma, int is_screen) |
|
static png_fixed_point | convert_gamma_value (png_structrp png_ptr, double output_gamma) |
|
void PNGFAPI | png_set_alpha_mode_fixed (png_structrp png_ptr, int mode, png_fixed_point output_gamma) |
|
void PNGAPI | png_set_alpha_mode (png_structrp png_ptr, int mode, double output_gamma) |
|
void PNGAPI | png_set_quantize (png_structrp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_const_uint_16p histogram, int full_quantize) |
|
void PNGFAPI | png_set_gamma_fixed (png_structrp png_ptr, png_fixed_point scrn_gamma, png_fixed_point file_gamma) |
|
void PNGAPI | png_set_gamma (png_structrp png_ptr, double scrn_gamma, double file_gamma) |
|
void PNGAPI | png_set_expand (png_structrp png_ptr) |
|
void PNGAPI | png_set_palette_to_rgb (png_structrp png_ptr) |
|
void PNGAPI | png_set_expand_gray_1_2_4_to_8 (png_structrp png_ptr) |
|
void PNGAPI | png_set_tRNS_to_alpha (png_structrp png_ptr) |
|
void PNGAPI | png_set_expand_16 (png_structrp png_ptr) |
|
void PNGAPI | png_set_gray_to_rgb (png_structrp png_ptr) |
|
void PNGFAPI | png_set_rgb_to_gray_fixed (png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green) |
|
void PNGAPI | png_set_rgb_to_gray (png_structrp png_ptr, int error_action, double red, double green) |
|
void PNGAPI | png_set_read_user_transform_fn (png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn) |
|
static int | png_gamma_threshold (png_fixed_point screen_gamma, png_fixed_point file_gamma) |
|
static void | png_init_palette_transformations (png_structrp png_ptr) |
|
static void | png_init_rgb_transformations (png_structrp png_ptr) |
|
void | png_init_read_transformations (png_structrp png_ptr) |
|
void | png_read_transform_info (png_structrp png_ptr, png_inforp info_ptr) |
|
static void | png_do_unpack (png_row_infop row_info, png_bytep row) |
|
static void | png_do_unshift (png_row_infop row_info, png_bytep row, png_const_color_8p sig_bits) |
|
static void | png_do_scale_16_to_8 (png_row_infop row_info, png_bytep row) |
|
static void | png_do_chop (png_row_infop row_info, png_bytep row) |
|
static void | png_do_read_swap_alpha (png_row_infop row_info, png_bytep row) |
|
static void | png_do_read_invert_alpha (png_row_infop row_info, png_bytep row) |
|
static void | png_do_read_filler (png_row_infop row_info, png_bytep row, png_uint_32 filler, png_uint_32 flags) |
|
static void | png_do_gray_to_rgb (png_row_infop row_info, png_bytep row) |
|
static int | png_do_rgb_to_gray (png_structrp png_ptr, png_row_infop row_info, png_bytep row) |
|
static void | png_do_compose (png_row_infop row_info, png_bytep row, png_structrp png_ptr) |
|
static void | png_do_gamma (png_row_infop row_info, png_bytep row, png_structrp png_ptr) |
|
static void | png_do_encode_alpha (png_row_infop row_info, png_bytep row, png_structrp png_ptr) |
|
static void | png_do_expand_palette (png_structrp png_ptr, png_row_infop row_info, png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) |
|
static void | png_do_expand (png_row_infop row_info, png_bytep row, png_const_color_16p trans_color) |
|
static void | png_do_expand_16 (png_row_infop row_info, png_bytep row) |
|
static void | png_do_quantize (png_row_infop row_info, png_bytep row, png_const_bytep palette_lookup, png_const_bytep quantize_lookup) |
|
void | png_do_read_transformations (png_structrp png_ptr, png_row_infop row_info) |
|
◆ CHOP
◆ png_dsort
◆ png_dsortp
◆ png_dsortpp
◆ png_set_crc_action()
62 "Can't discard critical data on CRC error");
◆ png_rtran_ok()
static int png_rtran_ok |
( |
png_structrp |
png_ptr, |
|
|
int |
need_IHDR |
|
) |
| |
|
static |
116 "invalid after png_start_read_image or png_read_update_info");
◆ png_set_background_fixed()
141 png_debug(1,
"in png_set_background_fixed");
157 png_ptr->background_gamma = background_gamma;
◆ png_set_background()
◆ png_set_scale_16()
◆ png_set_strip_16()
◆ png_set_strip_alpha()
◆ translate_gamma_flags()
237 # ifdef PNG_READ_sRGB_SUPPORTED
◆ convert_gamma_value()
271 if (output_gamma > 0 && output_gamma < 128)
275 output_gamma = floor(output_gamma + .5);
278 png_fixed_error(
png_ptr,
"gamma value");
◆ png_set_alpha_mode_fixed()
309 if (output_gamma < 1000 || output_gamma > 10000000)
370 if (
png_ptr->colorspace.gamma == 0)
372 png_ptr->colorspace.gamma = file_gamma;
373 png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
377 png_ptr->screen_gamma = output_gamma;
392 "conflicting calls to set alpha mode and background");
◆ png_set_alpha_mode()
◆ png_set_quantize()
439 if (full_quantize == 0)
445 for (
i = 0;
i < num_palette;
i++)
446 png_ptr->quantize_index[
i] = (png_byte)
i;
449 if (num_palette > maximum_colors)
451 if (histogram !=
NULL)
464 for (
i = 0;
i < num_palette;
i++)
474 for (
i = num_palette - 1;
i >= maximum_colors;
i--)
480 for (j = 0; j <
i; j++)
482 if (histogram[
png_ptr->quantize_sort[j]]
483 < histogram[
png_ptr->quantize_sort[j + 1]])
489 png_ptr->quantize_sort[j + 1] = t;
499 if (full_quantize != 0)
506 for (
i = 0;
i < maximum_colors;
i++)
508 if ((
int)
png_ptr->quantize_sort[
i] >= maximum_colors)
512 while ((
int)
png_ptr->quantize_sort[j] >= maximum_colors);
514 palette[
i] = palette[j];
525 for (
i = 0;
i < maximum_colors;
i++)
528 if ((
int)
png_ptr->quantize_sort[
i] >= maximum_colors)
534 while ((
int)
png_ptr->quantize_sort[j] >= maximum_colors);
536 tmp_color = palette[j];
537 palette[j] = palette[
i];
538 palette[
i] = tmp_color;
540 png_ptr->quantize_index[j] = (png_byte)
i;
541 png_ptr->quantize_index[
i] = (png_byte)j;
546 for (
i = 0;
i < num_palette;
i++)
548 if ((
int)
png_ptr->quantize_index[
i] >= maximum_colors)
550 int min_d, k, min_k, d_index;
553 d_index =
png_ptr->quantize_index[
i];
555 for (k = 1, min_k = 0; k < maximum_colors; k++)
568 png_ptr->quantize_index[
i] = (png_byte)min_k;
596 (
sizeof (png_byte))));
599 (
sizeof (png_byte))));
602 for (
i = 0;
i < num_palette;
i++)
604 png_ptr->index_to_palette[
i] = (png_byte)
i;
605 png_ptr->palette_to_index[
i] = (png_byte)
i;
611 num_new_palette = num_palette;
623 while (num_new_palette > maximum_colors)
625 for (
i = 0;
i < num_new_palette - 1;
i++)
629 for (j =
i + 1; j < num_new_palette; j++)
645 t->
left = (png_byte)
i;
646 t->
right = (png_byte)j;
655 for (
i = 0;
i <= max_d;
i++)
661 for (p = hash[
i]; p; p = p->
next)
670 if (num_new_palette & 0x01)
682 palette[
png_ptr->index_to_palette[j]]
683 = palette[num_new_palette];
684 if (full_quantize == 0)
688 for (k = 0; k < num_palette; k++)
690 if (
png_ptr->quantize_index[k] ==
693 png_ptr->index_to_palette[next_j];
695 if ((
int)
png_ptr->quantize_index[k] ==
703 [num_new_palette]] =
png_ptr->index_to_palette[j];
706 =
png_ptr->palette_to_index[num_new_palette];
709 (png_byte)num_new_palette;
711 png_ptr->palette_to_index[num_new_palette] =
714 if (num_new_palette <= maximum_colors)
717 if (num_new_palette <= maximum_colors)
722 for (
i = 0;
i < 769;
i++)
744 num_palette = maximum_colors;
752 if (full_quantize != 0)
761 size_t num_entries = ((size_t)1 << total_bits);
767 (
sizeof (png_byte))));
769 memset(distance, 0xff, num_entries * (
sizeof (png_byte)));
771 for (
i = 0;
i < num_palette;
i++)
778 for (ir = 0; ir < num_red; ir++)
781 int dr = ((ir > r) ? ir - r : r - ir);
785 for (ig = 0; ig < num_green; ig++)
788 int dg = ((ig > g) ? ig - g : g - ig);
790 int dm = ((dr > dg) ? dr : dg);
793 for (ib = 0; ib < num_blue; ib++)
795 int d_index = index_g | ib;
797 int db = ((ib >
b) ? ib -
b :
b - ib);
798 int dmax = ((dm > db) ? dm : db);
799 int d = dmax + dt + db;
801 if (d < (
int)distance[d_index])
803 distance[d_index] = (png_byte)d;
804 png_ptr->palette_lookup[d_index] = (png_byte)
i;
◆ png_set_gamma_fixed()
851 png_ptr->colorspace.gamma = file_gamma;
852 png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
853 png_ptr->screen_gamma = scrn_gamma;
◆ png_set_gamma()
◆ png_set_expand()
◆ png_set_palette_to_rgb()
904 png_debug(1,
"in png_set_palette_to_rgb");
◆ png_set_expand_gray_1_2_4_to_8()
916 png_debug(1,
"in png_set_expand_gray_1_2_4_to_8");
◆ png_set_tRNS_to_alpha()
928 png_debug(1,
"in png_set_tRNS_to_alpha");
◆ png_set_expand_16()
◆ png_set_gray_to_rgb()
◆ png_set_rgb_to_gray_fixed()
999 #ifdef PNG_READ_EXPAND_SUPPORTED
1007 "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED");
1025 png_ptr->rgb_to_gray_red_coeff = red_int;
1026 png_ptr->rgb_to_gray_green_coeff = green_int;
1027 png_ptr->rgb_to_gray_coefficients_set = 1;
1032 if (
red >= 0 && green >= 0)
1034 "ignoring out of range rgb_to_gray coefficients");
1042 if (
png_ptr->rgb_to_gray_red_coeff == 0 &&
1043 png_ptr->rgb_to_gray_green_coeff == 0)
1045 png_ptr->rgb_to_gray_red_coeff = 6968;
1046 png_ptr->rgb_to_gray_green_coeff = 23434;
◆ png_set_rgb_to_gray()
◆ png_set_read_user_transform_fn()
void PNGAPI png_set_read_user_transform_fn |
( |
png_structrp |
png_ptr, |
|
|
png_user_transform_ptr |
read_user_transform_fn |
|
) |
| |
1076 png_debug(1,
"in png_set_read_user_transform_fn");
1078 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
1080 png_ptr->read_user_transform_fn = read_user_transform_fn;
◆ png_gamma_threshold()
◆ png_init_palette_transformations()
1127 int input_has_alpha = 0;
1128 int input_has_transparency = 0;
1137 if (
png_ptr->trans_alpha[
i] == 255)
1139 else if (
png_ptr->trans_alpha[
i] == 0)
1140 input_has_transparency = 1;
1143 input_has_transparency = 1;
1144 input_has_alpha = 1;
1151 if (input_has_alpha == 0)
1160 if (input_has_transparency == 0)
1164 #if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
1184 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
1194 for (
i=0;
i<istop;
i++)
1195 png_ptr->trans_alpha[
i] = (png_byte)(255 -
◆ png_init_rgb_transformations()
1213 int input_has_transparency =
png_ptr->num_trans > 0;
1216 if (input_has_alpha == 0)
1222 # ifdef PNG_READ_ALPHA_MODE_SUPPORTED
1227 if (input_has_transparency == 0)
1231 #if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
1247 int gray =
png_ptr->background.gray;
1248 int trans_gray =
png_ptr->trans_color.gray;
◆ png_init_read_transformations()
1293 png_debug(1,
"in png_init_read_transformations");
1303 #ifdef PNG_READ_GAMMA_SUPPORTED
1314 int gamma_correction = 0;
1316 if (
png_ptr->colorspace.gamma != 0)
1318 if (
png_ptr->screen_gamma != 0)
1329 else if (
png_ptr->screen_gamma != 0)
1346 png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
1356 if (gamma_correction != 0)
1393 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
1417 #ifdef PNG_READ_ALPHA_MODE_SUPPORTED
1428 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
1436 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
1437 #if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
1499 #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
1500 defined(PNG_READ_EXPAND_16_SUPPORTED)
1516 # define CHOP(x) (x)=((png_uint_16)PNG_DIV257(x))
1525 #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
1526 (defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \
1527 defined(PNG_READ_STRIP_16_TO_8_SUPPORTED))
1555 #ifdef PNG_READ_GAMMA_SUPPORTED
1556 # ifdef PNG_READ_BACKGROUND_SUPPORTED
1581 # ifdef PNG_READ_BACKGROUND_SUPPORTED
1590 #ifdef PNG_READ_BACKGROUND_SUPPORTED
1601 "libpng does not support gamma+background+rgb_to_gray");
1610 int num_palette =
png_ptr->num_palette;
1627 switch (
png_ptr->background_gamma_type)
1663 back.
red = (png_byte)
png_ptr->background.red;
1673 png_ptr->background.green, g);
1680 back_1.
red = (png_byte)
png_ptr->background.red;
1686 for (
i = 0;
i < num_palette;
i++)
1736 switch (
png_ptr->background_gamma_type)
1768 png_ptr->background.gray, gs);
1781 png_ptr->background.green, g);
1793 png_ptr->background.green, gs);
1796 png_ptr->background.blue, gs);
1827 int num_palette =
png_ptr->num_palette;
1833 for (
i = 0;
i < num_palette;
i++)
1844 #ifdef PNG_READ_BACKGROUND_SUPPORTED
1849 #ifdef PNG_READ_BACKGROUND_SUPPORTED
1859 back.
red = (png_byte)
png_ptr->background.red;
1863 for (
i = 0;
i < istop;
i++)
1870 else if (
png_ptr->trans_alpha[
i] != 0xff)
1888 #ifdef PNG_READ_SHIFT_SUPPORTED
1894 int istop =
png_ptr->num_palette;
1895 int shift = 8 -
png_ptr->sig_bit.red;
1903 if (shift > 0 && shift < 8)
1904 for (
i=0;
i<istop; ++
i)
1906 int component =
png_ptr->palette[
i].red;
1908 component >>= shift;
1909 png_ptr->palette[
i].red = (png_byte)component;
1912 shift = 8 -
png_ptr->sig_bit.green;
1913 if (shift > 0 && shift < 8)
1914 for (
i=0;
i<istop; ++
i)
1916 int component =
png_ptr->palette[
i].green;
1918 component >>= shift;
1919 png_ptr->palette[
i].green = (png_byte)component;
1922 shift = 8 -
png_ptr->sig_bit.blue;
1923 if (shift > 0 && shift < 8)
1924 for (
i=0;
i<istop; ++
i)
1926 int component =
png_ptr->palette[
i].blue;
1928 component >>= shift;
1929 png_ptr->palette[
i].blue = (png_byte)component;
◆ png_read_transform_info()
1942 png_debug(1,
"in png_read_transform_info");
1944 #ifdef PNG_READ_EXPAND_SUPPORTED
1980 #if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
1981 defined(PNG_READ_ALPHA_MODE_SUPPORTED)
1989 #ifdef PNG_READ_GAMMA_SUPPORTED
2004 # ifdef PNG_READ_16BIT_SUPPORTED
2005 # ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
2010 # ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
2020 # ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
2029 # ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
2034 CONFIGURATION ERROR: you must enable at least one 16 to 8 method
2040 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
2046 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
2052 #ifdef PNG_READ_QUANTIZE_SUPPORTED
2064 #ifdef PNG_READ_EXPAND_16_SUPPORTED
2073 #ifdef PNG_READ_PACK_SUPPORTED
2113 #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
2114 defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
2117 if (
png_ptr->user_transform_depth != 0)
2120 if (
png_ptr->user_transform_channels != 0)
2138 #ifndef PNG_READ_EXPAND_SUPPORTED
◆ png_do_unpack()
2165 png_bytep sp = row + (size_t)((row_width - 1) >> 3);
2166 png_bytep dp = row + (size_t)row_width - 1;
2167 png_uint_32 shift = 7U - ((row_width + 7U) & 0x07);
2168 for (
i = 0;
i < row_width;
i++)
2170 *dp = (png_byte)((*sp >> shift) & 0x01);
2189 png_bytep sp = row + (size_t)((row_width - 1) >> 2);
2190 png_bytep dp = row + (size_t)row_width - 1;
2191 png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1);
2192 for (
i = 0;
i < row_width;
i++)
2194 *dp = (png_byte)((*sp >> shift) & 0x03);
2212 png_bytep sp = row + (size_t)((row_width - 1) >> 1);
2213 png_bytep dp = row + (size_t)row_width - 1;
2214 png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2);
2215 for (
i = 0;
i < row_width;
i++)
2217 *dp = (png_byte)((*sp >> shift) & 0x0f);
◆ png_do_unshift()
2268 shift[channels++] = bit_depth - sig_bits->red;
2269 shift[channels++] = bit_depth - sig_bits->green;
2270 shift[channels++] = bit_depth - sig_bits->blue;
2275 shift[channels++] = bit_depth - sig_bits->gray;
2280 shift[channels++] = bit_depth - sig_bits->alpha;
2286 for (c = have_shift = 0; c < channels; ++c)
2291 if (shift[c] <= 0 || shift[c] >= bit_depth)
2298 if (have_shift == 0)
2318 int b = (*bp >> 1) & 0x55;
2319 *bp++ = (png_byte)
b;
2330 int gray_shift = shift[0];
2331 int mask = 0xf >> gray_shift;
2337 int b = (*bp >> gray_shift) & mask;
2338 *bp++ = (png_byte)
b;
2352 int b = *bp >> shift[channel];
2353 if (++channel >= channels)
2355 *bp++ = (png_byte)
b;
2360 #ifdef PNG_READ_16BIT_SUPPORTED
2370 int value = (bp[0] << 8) + bp[1];
2372 value >>= shift[channel];
2373 if (++channel >= channels)
2375 *bp++ = (png_byte)(value >> 8);
2376 *bp++ = (png_byte)value;
◆ png_do_scale_16_to_8()
2391 png_debug(1,
"in png_do_scale_16_to_8");
2434 tmp += (((
int)*sp++ - tmp + 128) * 65535) >> 24;
2435 *dp++ = (png_byte)tmp;
◆ png_do_chop()
◆ png_do_read_swap_alpha()
2479 png_debug(1,
"in png_do_read_swap_alpha");
2491 for (
i = 0;
i < row_width;
i++)
2501 #ifdef PNG_READ_16BIT_SUPPORTED
2510 for (
i = 0;
i < row_width;
i++)
2537 for (
i = 0;
i < row_width;
i++)
2545 #ifdef PNG_READ_16BIT_SUPPORTED
2554 for (
i = 0;
i < row_width;
i++)
◆ png_do_read_invert_alpha()
2574 png_debug(1,
"in png_do_read_invert_alpha");
2576 row_width = row_info->
width;
2586 for (
i = 0;
i < row_width;
i++)
2588 *(--dp) = (png_byte)(255 - *(--sp));
2601 #ifdef PNG_READ_16BIT_SUPPORTED
2609 for (
i = 0;
i < row_width;
i++)
2611 *(--dp) = (png_byte)(255 - *(--sp));
2612 *(--dp) = (png_byte)(255 - *(--sp));
2638 for (
i = 0;
i < row_width;
i++)
2640 *(--dp) = (png_byte)(255 - *(--sp));
2645 #ifdef PNG_READ_16BIT_SUPPORTED
2653 for (
i = 0;
i < row_width;
i++)
2655 *(--dp) = (png_byte)(255 - *(--sp));
2656 *(--dp) = (png_byte)(255 - *(--sp));
◆ png_do_read_filler()
2679 #ifdef PNG_READ_16BIT_SUPPORTED
2680 png_byte hi_filler = (png_byte)(filler>>8);
2682 png_byte lo_filler = (png_byte)filler;
2696 for (
i = 1;
i < row_width;
i++)
2698 *(--dp) = lo_filler;
2701 *(--dp) = lo_filler;
2704 row_info->
rowbytes = row_width * 2;
2712 for (
i = 0;
i < row_width;
i++)
2715 *(--dp) = lo_filler;
2719 row_info->
rowbytes = row_width * 2;
2723 #ifdef PNG_READ_16BIT_SUPPORTED
2729 png_bytep sp = row + (size_t)row_width * 2;
2730 png_bytep dp = sp + (size_t)row_width * 2;
2731 for (
i = 1;
i < row_width;
i++)
2733 *(--dp) = lo_filler;
2734 *(--dp) = hi_filler;
2738 *(--dp) = lo_filler;
2739 *(--dp) = hi_filler;
2742 row_info->
rowbytes = row_width * 4;
2748 png_bytep sp = row + (size_t)row_width * 2;
2749 png_bytep dp = sp + (size_t)row_width * 2;
2750 for (
i = 0;
i < row_width;
i++)
2754 *(--dp) = lo_filler;
2755 *(--dp) = hi_filler;
2759 row_info->
rowbytes = row_width * 4;
2771 png_bytep sp = row + (size_t)row_width * 3;
2773 for (
i = 1;
i < row_width;
i++)
2775 *(--dp) = lo_filler;
2780 *(--dp) = lo_filler;
2783 row_info->
rowbytes = row_width * 4;
2789 png_bytep sp = row + (size_t)row_width * 3;
2791 for (
i = 0;
i < row_width;
i++)
2796 *(--dp) = lo_filler;
2800 row_info->
rowbytes = row_width * 4;
2804 #ifdef PNG_READ_16BIT_SUPPORTED
2810 png_bytep sp = row + (size_t)row_width * 6;
2811 png_bytep dp = sp + (size_t)row_width * 2;
2812 for (
i = 1;
i < row_width;
i++)
2814 *(--dp) = lo_filler;
2815 *(--dp) = hi_filler;
2823 *(--dp) = lo_filler;
2824 *(--dp) = hi_filler;
2827 row_info->
rowbytes = row_width * 8;
2833 png_bytep sp = row + (size_t)row_width * 6;
2834 png_bytep dp = sp + (size_t)row_width * 2;
2835 for (
i = 0;
i < row_width;
i++)
2843 *(--dp) = lo_filler;
2844 *(--dp) = hi_filler;
2849 row_info->
rowbytes = row_width * 8;
◆ png_do_gray_to_rgb()
2875 png_bytep sp = row + (size_t)row_width - 1;
2876 png_bytep dp = sp + (size_t)row_width * 2;
2877 for (
i = 0;
i < row_width;
i++)
2888 png_bytep sp = row + (size_t)row_width * 2 - 1;
2889 png_bytep dp = sp + (size_t)row_width * 4;
2890 for (
i = 0;
i < row_width;
i++)
2893 *(dp--) = *(sp - 1);
2895 *(dp--) = *(sp - 1);
2907 png_bytep sp = row + (size_t)row_width * 2 - 1;
2908 png_bytep dp = sp + (size_t)row_width * 2;
2909 for (
i = 0;
i < row_width;
i++)
2921 png_bytep sp = row + (size_t)row_width * 4 - 1;
2922 png_bytep dp = sp + (size_t)row_width * 4;
2923 for (
i = 0;
i < row_width;
i++)
2928 *(dp--) = *(sp - 1);
2930 *(dp--) = *(sp - 1);
◆ png_do_rgb_to_gray()
3016 #ifdef PNG_READ_GAMMA_SUPPORTED
3028 for (
i = 0;
i < row_width;
i++)
3030 png_byte
red = *(sp++);
3031 png_byte green = *(sp++);
3032 png_byte blue = *(sp++);
3034 if (
red != green ||
red != blue)
3037 green =
png_ptr->gamma_to_1[green];
3038 blue =
png_ptr->gamma_to_1[blue];
3041 *(dp++) =
png_ptr->gamma_from_1[
3042 (rc*
red + gc*green + bc*blue + 16384)>>15];
3056 if (have_alpha != 0)
3067 for (
i = 0;
i < row_width;
i++)
3069 png_byte
red = *(sp++);
3070 png_byte green = *(sp++);
3071 png_byte blue = *(sp++);
3073 if (
red != green ||
red != blue)
3079 *(dp++) = (png_byte)((rc*
red + gc*green + bc*blue)>>15);
3085 if (have_alpha != 0)
3093 #ifdef PNG_READ_GAMMA_SUPPORTED
3100 for (
i = 0;
i < row_width;
i++)
3106 hi=*(sp)++; lo=*(sp)++; green = (
png_uint_16)((hi << 8) | (lo));
3107 hi=*(sp)++; lo=*(sp)++; blue = (
png_uint_16)((hi << 8) | (lo));
3109 if (
red == green &&
red == blue)
3124 png_ptr->gamma_16_to_1[(green & 0xff) >>
3125 png_ptr->gamma_shift][green>>8];
3127 >>
png_ptr->gamma_shift][blue>>8];
3129 + bc*blue_1 + 16384)>>15);
3130 w =
png_ptr->gamma_16_from_1[(gray16 & 0xff) >>
3131 png_ptr->gamma_shift][gray16 >> 8];
3135 *(dp++) = (png_byte)((w>>8) & 0xff);
3136 *(dp++) = (png_byte)(w & 0xff);
3138 if (have_alpha != 0)
3152 for (
i = 0;
i < row_width;
i++)
3158 hi=*(sp)++; lo=*(sp)++; green = (
png_uint_16)((hi << 8) | (lo));
3159 hi=*(sp)++; lo=*(sp)++; blue = (
png_uint_16)((hi << 8) | (lo));
3161 if (
red != green ||
red != blue)
3170 *(dp++) = (png_byte)((gray16 >> 8) & 0xff);
3171 *(dp++) = (png_byte)(gray16 & 0xff);
3173 if (have_alpha != 0)
◆ png_do_compose()
3202 #ifdef PNG_READ_GAMMA_SUPPORTED
3209 int gamma_shift =
png_ptr->gamma_shift;
3230 for (
i = 0;
i < row_width;
i++)
3235 unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
3237 (
unsigned int)(
png_ptr->background.gray << shift);
3238 *sp = (png_byte)(tmp & 0xff);
3255 #ifdef PNG_READ_GAMMA_SUPPORTED
3256 if (gamma_table !=
NULL)
3260 for (
i = 0;
i < row_width;
i++)
3265 unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
3267 (
unsigned int)
png_ptr->background.gray << shift;
3268 *sp = (png_byte)(tmp & 0xff);
3273 unsigned int p = (*sp >> shift) & 0x03;
3274 unsigned int g = (gamma_table [p | (p << 2) |
3275 (p << 4) | (p << 6)] >> 6) & 0x03;
3276 unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
3277 tmp |= (
unsigned int)(g << shift);
3278 *sp = (png_byte)(tmp & 0xff);
3297 for (
i = 0;
i < row_width;
i++)
3302 unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
3304 (
unsigned int)
png_ptr->background.gray << shift;
3305 *sp = (png_byte)(tmp & 0xff);
3323 #ifdef PNG_READ_GAMMA_SUPPORTED
3324 if (gamma_table !=
NULL)
3328 for (
i = 0;
i < row_width;
i++)
3333 unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
3335 (
unsigned int)(
png_ptr->background.gray << shift);
3336 *sp = (png_byte)(tmp & 0xff);
3341 unsigned int p = (*sp >> shift) & 0x0f;
3342 unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
3344 unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
3345 tmp |= (
unsigned int)(g << shift);
3346 *sp = (png_byte)(tmp & 0xff);
3365 for (
i = 0;
i < row_width;
i++)
3370 unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
3372 (
unsigned int)(
png_ptr->background.gray << shift);
3373 *sp = (png_byte)(tmp & 0xff);
3391 #ifdef PNG_READ_GAMMA_SUPPORTED
3392 if (gamma_table !=
NULL)
3395 for (
i = 0;
i < row_width;
i++, sp++)
3397 if (*sp ==
png_ptr->trans_color.gray)
3398 *sp = (png_byte)
png_ptr->background.gray;
3401 *sp = gamma_table[*sp];
3408 for (
i = 0;
i < row_width;
i++, sp++)
3410 if (*sp ==
png_ptr->trans_color.gray)
3411 *sp = (png_byte)
png_ptr->background.gray;
3419 #ifdef PNG_READ_GAMMA_SUPPORTED
3420 if (gamma_16 !=
NULL)
3423 for (
i = 0;
i < row_width;
i++, sp += 2)
3429 if (v ==
png_ptr->trans_color.gray)
3432 *sp = (png_byte)((
png_ptr->background.gray >> 8)
3434 *(sp + 1) = (png_byte)(
png_ptr->background.gray
3440 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3441 *sp = (png_byte)((v >> 8) & 0xff);
3442 *(sp + 1) = (png_byte)(v & 0xff);
3450 for (
i = 0;
i < row_width;
i++, sp += 2)
3456 if (v ==
png_ptr->trans_color.gray)
3458 *sp = (png_byte)((
png_ptr->background.gray >> 8)
3460 *(sp + 1) = (png_byte)(
png_ptr->background.gray
3478 #ifdef PNG_READ_GAMMA_SUPPORTED
3479 if (gamma_table !=
NULL)
3482 for (
i = 0;
i < row_width;
i++, sp += 3)
3484 if (*sp ==
png_ptr->trans_color.red &&
3485 *(sp + 1) ==
png_ptr->trans_color.green &&
3486 *(sp + 2) ==
png_ptr->trans_color.blue)
3488 *sp = (png_byte)
png_ptr->background.red;
3489 *(sp + 1) = (png_byte)
png_ptr->background.green;
3490 *(sp + 2) = (png_byte)
png_ptr->background.blue;
3495 *sp = gamma_table[*sp];
3496 *(sp + 1) = gamma_table[*(sp + 1)];
3497 *(sp + 2) = gamma_table[*(sp + 2)];
3505 for (
i = 0;
i < row_width;
i++, sp += 3)
3507 if (*sp ==
png_ptr->trans_color.red &&
3508 *(sp + 1) ==
png_ptr->trans_color.green &&
3509 *(sp + 2) ==
png_ptr->trans_color.blue)
3511 *sp = (png_byte)
png_ptr->background.red;
3512 *(sp + 1) = (png_byte)
png_ptr->background.green;
3513 *(sp + 2) = (png_byte)
png_ptr->background.blue;
3520 #ifdef PNG_READ_GAMMA_SUPPORTED
3521 if (gamma_16 !=
NULL)
3524 for (
i = 0;
i < row_width;
i++, sp += 6)
3534 if (r ==
png_ptr->trans_color.red &&
3535 g ==
png_ptr->trans_color.green &&
3539 *sp = (png_byte)((
png_ptr->background.red >> 8) & 0xff);
3540 *(sp + 1) = (png_byte)(
png_ptr->background.red & 0xff);
3541 *(sp + 2) = (png_byte)((
png_ptr->background.green >> 8)
3543 *(sp + 3) = (png_byte)(
png_ptr->background.green
3545 *(sp + 4) = (png_byte)((
png_ptr->background.blue >> 8)
3547 *(sp + 5) = (png_byte)(
png_ptr->background.blue & 0xff);
3552 png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3553 *sp = (png_byte)((v >> 8) & 0xff);
3554 *(sp + 1) = (png_byte)(v & 0xff);
3556 v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
3557 *(sp + 2) = (png_byte)((v >> 8) & 0xff);
3558 *(sp + 3) = (png_byte)(v & 0xff);
3560 v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
3561 *(sp + 4) = (png_byte)((v >> 8) & 0xff);
3562 *(sp + 5) = (png_byte)(v & 0xff);
3571 for (
i = 0;
i < row_width;
i++, sp += 6)
3581 if (r ==
png_ptr->trans_color.red &&
3582 g ==
png_ptr->trans_color.green &&
3585 *sp = (png_byte)((
png_ptr->background.red >> 8) & 0xff);
3586 *(sp + 1) = (png_byte)(
png_ptr->background.red & 0xff);
3587 *(sp + 2) = (png_byte)((
png_ptr->background.green >> 8)
3589 *(sp + 3) = (png_byte)(
png_ptr->background.green
3591 *(sp + 4) = (png_byte)((
png_ptr->background.blue >> 8)
3593 *(sp + 5) = (png_byte)(
png_ptr->background.blue & 0xff);
3605 #ifdef PNG_READ_GAMMA_SUPPORTED
3606 if (gamma_to_1 !=
NULL && gamma_from_1 !=
NULL &&
3607 gamma_table !=
NULL)
3610 for (
i = 0;
i < row_width;
i++, sp += 2)
3615 *sp = gamma_table[*sp];
3620 *sp = (png_byte)
png_ptr->background.gray;
3627 v = gamma_to_1[*sp];
3630 w = gamma_from_1[w];
3639 for (
i = 0;
i < row_width;
i++, sp += 2)
3641 png_byte
a = *(sp + 1);
3644 *sp = (png_byte)
png_ptr->background.gray;
3653 #ifdef PNG_READ_GAMMA_SUPPORTED
3654 if (gamma_16 !=
NULL && gamma_16_from_1 !=
NULL &&
3655 gamma_16_to_1 !=
NULL)
3658 for (
i = 0;
i < row_width;
i++, sp += 4)
3667 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3668 *sp = (png_byte)((v >> 8) & 0xff);
3669 *(sp + 1) = (png_byte)(v & 0xff);
3675 *sp = (png_byte)((
png_ptr->background.gray >> 8)
3677 *(sp + 1) = (png_byte)(
png_ptr->background.gray & 0xff);
3684 g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
3689 w = gamma_16_from_1[(v & 0xff) >>
3690 gamma_shift][v >> 8];
3691 *sp = (png_byte)((w >> 8) & 0xff);
3692 *(sp + 1) = (png_byte)(w & 0xff);
3700 for (
i = 0;
i < row_width;
i++, sp += 4)
3707 *sp = (png_byte)((
png_ptr->background.gray >> 8)
3709 *(sp + 1) = (png_byte)(
png_ptr->background.gray & 0xff);
3712 else if (
a < 0xffff)
3718 *sp = (png_byte)((v >> 8) & 0xff);
3719 *(sp + 1) = (png_byte)(v & 0xff);
3731 #ifdef PNG_READ_GAMMA_SUPPORTED
3732 if (gamma_to_1 !=
NULL && gamma_from_1 !=
NULL &&
3733 gamma_table !=
NULL)
3736 for (
i = 0;
i < row_width;
i++, sp += 4)
3738 png_byte
a = *(sp + 3);
3742 *sp = gamma_table[*sp];
3743 *(sp + 1) = gamma_table[*(sp + 1)];
3744 *(sp + 2) = gamma_table[*(sp + 2)];
3750 *sp = (png_byte)
png_ptr->background.red;
3751 *(sp + 1) = (png_byte)
png_ptr->background.green;
3752 *(sp + 2) = (png_byte)
png_ptr->background.blue;
3759 v = gamma_to_1[*sp];
3761 if (optimize == 0) w = gamma_from_1[w];
3764 v = gamma_to_1[*(sp + 1)];
3766 if (optimize == 0) w = gamma_from_1[w];
3769 v = gamma_to_1[*(sp + 2)];
3771 if (optimize == 0) w = gamma_from_1[w];
3780 for (
i = 0;
i < row_width;
i++, sp += 4)
3782 png_byte
a = *(sp + 3);
3786 *sp = (png_byte)
png_ptr->background.red;
3787 *(sp + 1) = (png_byte)
png_ptr->background.green;
3788 *(sp + 2) = (png_byte)
png_ptr->background.blue;
3806 #ifdef PNG_READ_GAMMA_SUPPORTED
3807 if (gamma_16 !=
NULL && gamma_16_from_1 !=
NULL &&
3808 gamma_16_to_1 !=
NULL)
3811 for (
i = 0;
i < row_width;
i++, sp += 8)
3820 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
3821 *sp = (png_byte)((v >> 8) & 0xff);
3822 *(sp + 1) = (png_byte)(v & 0xff);
3824 v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
3825 *(sp + 2) = (png_byte)((v >> 8) & 0xff);
3826 *(sp + 3) = (png_byte)(v & 0xff);
3828 v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
3829 *(sp + 4) = (png_byte)((v >> 8) & 0xff);
3830 *(sp + 5) = (png_byte)(v & 0xff);
3836 *sp = (png_byte)((
png_ptr->background.red >> 8) & 0xff);
3837 *(sp + 1) = (png_byte)(
png_ptr->background.red & 0xff);
3838 *(sp + 2) = (png_byte)((
png_ptr->background.green >> 8)
3840 *(sp + 3) = (png_byte)(
png_ptr->background.green
3842 *(sp + 4) = (png_byte)((
png_ptr->background.blue >> 8)
3844 *(sp + 5) = (png_byte)(
png_ptr->background.blue & 0xff);
3851 v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
3854 w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
3856 *sp = (png_byte)((w >> 8) & 0xff);
3857 *(sp + 1) = (png_byte)(w & 0xff);
3859 v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
3862 w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
3865 *(sp + 2) = (png_byte)((w >> 8) & 0xff);
3866 *(sp + 3) = (png_byte)(w & 0xff);
3868 v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
3871 w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
3874 *(sp + 4) = (png_byte)((w >> 8) & 0xff);
3875 *(sp + 5) = (png_byte)(w & 0xff);
3884 for (
i = 0;
i < row_width;
i++, sp += 8)
3891 *sp = (png_byte)((
png_ptr->background.red >> 8) & 0xff);
3892 *(sp + 1) = (png_byte)(
png_ptr->background.red & 0xff);
3893 *(sp + 2) = (png_byte)((
png_ptr->background.green >> 8)
3895 *(sp + 3) = (png_byte)(
png_ptr->background.green
3897 *(sp + 4) = (png_byte)((
png_ptr->background.blue >> 8)
3899 *(sp + 5) = (png_byte)(
png_ptr->background.blue & 0xff);
3902 else if (
a < 0xffff)
3913 *sp = (png_byte)((v >> 8) & 0xff);
3914 *(sp + 1) = (png_byte)(v & 0xff);
3917 *(sp + 2) = (png_byte)((v >> 8) & 0xff);
3918 *(sp + 3) = (png_byte)(v & 0xff);
3921 *(sp + 4) = (png_byte)((v >> 8) & 0xff);
3922 *(sp + 5) = (png_byte)(v & 0xff);
◆ png_do_gamma()
3948 int gamma_shift =
png_ptr->gamma_shift;
3966 for (
i = 0;
i < row_width;
i++)
3968 *sp = gamma_table[*sp];
3970 *sp = gamma_table[*sp];
3972 *sp = gamma_table[*sp];
3980 for (
i = 0;
i < row_width;
i++)
3984 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3985 *sp = (png_byte)((v >> 8) & 0xff);
3986 *(sp + 1) = (png_byte)(v & 0xff);
3989 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3990 *sp = (png_byte)((v >> 8) & 0xff);
3991 *(sp + 1) = (png_byte)(v & 0xff);
3994 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
3995 *sp = (png_byte)((v >> 8) & 0xff);
3996 *(sp + 1) = (png_byte)(v & 0xff);
4008 for (
i = 0;
i < row_width;
i++)
4010 *sp = gamma_table[*sp];
4013 *sp = gamma_table[*sp];
4016 *sp = gamma_table[*sp];
4026 for (
i = 0;
i < row_width;
i++)
4028 png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
4029 *sp = (png_byte)((v >> 8) & 0xff);
4030 *(sp + 1) = (png_byte)(v & 0xff);
4033 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
4034 *sp = (png_byte)((v >> 8) & 0xff);
4035 *(sp + 1) = (png_byte)(v & 0xff);
4038 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
4039 *sp = (png_byte)((v >> 8) & 0xff);
4040 *(sp + 1) = (png_byte)(v & 0xff);
4052 for (
i = 0;
i < row_width;
i++)
4054 *sp = gamma_table[*sp];
4062 for (
i = 0;
i < row_width;
i++)
4064 png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
4065 *sp = (png_byte)((v >> 8) & 0xff);
4066 *(sp + 1) = (png_byte)(v & 0xff);
4078 for (
i = 0;
i < row_width;
i += 4)
4086 ((((
int)gamma_table[
a|(
a>>2)|(
a>>4)|(
a>>6)]) ) & 0xc0)|
4087 ((((
int)gamma_table[(
b<<2)|
b|(
b>>2)|(
b>>4)])>>2) & 0x30)|
4088 ((((
int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)|
4089 ((((
int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) ));
4097 for (
i = 0;
i < row_width;
i += 2)
4099 int msb = *sp & 0xf0;
4100 int lsb = *sp & 0x0f;
4102 *sp = (png_byte)((((
int)gamma_table[msb | (msb >> 4)]) & 0xf0)
4103 | (((
int)gamma_table[(lsb << 4) | lsb]) >> 4));
4111 for (
i = 0;
i < row_width;
i++)
4113 *sp = gamma_table[*sp];
4121 for (
i = 0;
i < row_width;
i++)
4123 png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
4124 *sp = (png_byte)((v >> 8) & 0xff);
4125 *(sp + 1) = (png_byte)(v & 0xff);
◆ png_do_encode_alpha()
4164 for (; row_width > 0; --row_width, row += step)
4174 int gamma_shift =
png_ptr->gamma_shift;
4183 for (; row_width > 0; --row_width, row += step)
4187 v = table[*(row + 1) >> gamma_shift][*row];
4188 *row = (png_byte)((v >> 8) & 0xff);
4189 *(row + 1) = (png_byte)(v & 0xff);
◆ png_do_expand_palette()
4218 png_debug(1,
"in png_do_expand_palette");
4228 sp = row + (size_t)((row_width - 1) >> 3);
4229 dp = row + (size_t)row_width - 1;
4230 shift = 7 - (
int)((row_width + 7) & 0x07);
4231 for (
i = 0;
i < row_width;
i++)
4233 if ((*sp >> shift) & 0x01)
4255 sp = row + (size_t)((row_width - 1) >> 2);
4256 dp = row + (size_t)row_width - 1;
4257 shift = (
int)((3 - ((row_width + 3) & 0x03)) << 1);
4258 for (
i = 0;
i < row_width;
i++)
4260 value = (*sp >> shift) & 0x03;
4261 *dp = (png_byte)value;
4278 sp = row + (size_t)((row_width - 1) >> 1);
4279 dp = row + (size_t)row_width - 1;
4280 shift = (
int)((row_width & 0x01) << 2);
4281 for (
i = 0;
i < row_width;
i++)
4283 value = (*sp >> shift) & 0x0f;
4284 *dp = (png_byte)value;
4312 sp = row + (size_t)row_width - 1;
4313 dp = row + ((size_t)row_width << 2) - 1;
4316 #ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
4323 i = png_do_expand_palette_neon_rgba(
png_ptr, row_info, row,
4328 for (;
i < row_width;
i++)
4330 if ((
int)(*sp) >= num_trans)
4333 *dp-- = trans_alpha[*sp];
4334 *dp-- = palette[*sp].blue;
4335 *dp-- = palette[*sp].green;
4336 *dp-- = palette[*sp].red;
4341 row_info->
rowbytes = row_width * 4;
4348 sp = row + (size_t)row_width - 1;
4349 dp = row + (size_t)(row_width * 3) - 1;
4351 #ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
4352 i = png_do_expand_palette_neon_rgb(
png_ptr, row_info, row,
4356 for (;
i < row_width;
i++)
4358 *dp-- = palette[*sp].blue;
4359 *dp-- = palette[*sp].green;
4360 *dp-- = palette[*sp].red;
4366 row_info->
rowbytes = row_width * 3;
◆ png_do_expand()
4391 unsigned int gray = trans_color !=
NULL ? trans_color->gray : 0;
4399 gray = (gray & 0x01) * 0xff;
4400 sp = row + (size_t)((row_width - 1) >> 3);
4401 dp = row + (size_t)row_width - 1;
4402 shift = 7 - (
int)((row_width + 7) & 0x07);
4403 for (
i = 0;
i < row_width;
i++)
4405 if ((*sp >> shift) & 0x01)
4427 gray = (gray & 0x03) * 0x55;
4428 sp = row + (size_t)((row_width - 1) >> 2);
4429 dp = row + (size_t)row_width - 1;
4430 shift = (
int)((3 - ((row_width + 3) & 0x03)) << 1);
4431 for (
i = 0;
i < row_width;
i++)
4433 value = (*sp >> shift) & 0x03;
4434 *dp = (png_byte)(value | (value << 2) | (value << 4) |
4452 gray = (gray & 0x0f) * 0x11;
4453 sp = row + (size_t)((row_width - 1) >> 1);
4454 dp = row + (size_t)row_width - 1;
4455 shift = (
int)((1 - ((row_width + 1) & 0x01)) << 2);
4456 for (
i = 0;
i < row_width;
i++)
4458 value = (*sp >> shift) & 0x0f;
4459 *dp = (png_byte)(value | (value << 4));
4483 if (trans_color !=
NULL)
4488 sp = row + (size_t)row_width - 1;
4489 dp = row + ((size_t)row_width << 1) - 1;
4491 for (
i = 0;
i < row_width;
i++)
4493 if ((*sp & 0xffU) == gray)
4505 unsigned int gray_high = (gray >> 8) & 0xff;
4506 unsigned int gray_low = gray & 0xff;
4508 dp = row + (row_info->
rowbytes << 1) - 1;
4509 for (
i = 0;
i < row_width;
i++)
4511 if ((*(sp - 1) & 0xffU) == gray_high &&
4512 (*(sp) & 0xffU) == gray_low)
4537 trans_color !=
NULL)
4541 png_byte
red = (png_byte)(trans_color->red & 0xff);
4542 png_byte green = (png_byte)(trans_color->green & 0xff);
4543 png_byte blue = (png_byte)(trans_color->blue & 0xff);
4544 sp = row + (size_t)row_info->
rowbytes - 1;
4545 dp = row + ((
size_t)row_width << 2) - 1;
4546 for (
i = 0;
i < row_width;
i++)
4548 if (*(sp - 2) ==
red && *(sp - 1) == green && *(sp) == blue)
4561 png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff);
4562 png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff);
4563 png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff);
4564 png_byte red_low = (png_byte)(trans_color->red & 0xff);
4565 png_byte green_low = (png_byte)(trans_color->green & 0xff);
4566 png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
4568 dp = row + ((size_t)row_width << 3) - 1;
4569 for (
i = 0;
i < row_width;
i++)
4571 if (*(sp - 5) == red_high &&
4572 *(sp - 4) == red_low &&
4573 *(sp - 3) == green_high &&
4574 *(sp - 2) == green_low &&
4575 *(sp - 1) == blue_high &&
◆ png_do_expand_16()
4623 png_byte *sp = row + row_info->
rowbytes;
4624 png_byte *dp = sp + row_info->
rowbytes;
4627 dp[-2] = dp[-1] = *--sp; dp -= 2;
◆ png_do_quantize()
4655 for (
i = 0;
i < row_width;
i++)
4677 *dp++ = palette_lookup[p];
4687 palette_lookup !=
NULL)
4692 for (
i = 0;
i < row_width;
i++)
4708 *dp++ = palette_lookup[p];
4722 for (
i = 0;
i < row_width;
i++, sp++)
4724 *sp = quantize_lookup[*sp];
◆ png_do_read_transformations()
4738 png_debug(1,
"in png_do_read_transformations");
4765 #ifdef PNG_READ_EXPAND_SUPPORTED
4770 #ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
4780 png_riffle_palette_rgba(
png_ptr, row_info);
4790 if (
png_ptr->num_trans != 0 &&
4801 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
4810 #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
4819 png_ptr->rgb_to_gray_status=1;
4862 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
4871 #if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
4872 defined(PNG_READ_ALPHA_MODE_SUPPORTED)
4877 #ifdef PNG_READ_GAMMA_SUPPORTED
4899 #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
4908 #ifdef PNG_READ_ALPHA_MODE_SUPPORTED
4914 #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
4919 #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
4928 #ifdef PNG_READ_QUANTIZE_SUPPORTED
4939 #ifdef PNG_READ_EXPAND_16_SUPPORTED
4949 #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
4956 #ifdef PNG_READ_INVERT_SUPPORTED
4961 #ifdef PNG_READ_INVERT_ALPHA_SUPPORTED
4966 #ifdef PNG_READ_SHIFT_SUPPORTED
4972 #ifdef PNG_READ_PACK_SUPPORTED
4977 #ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
4980 png_ptr->num_palette_max >= 0)
4984 #ifdef PNG_READ_BGR_SUPPORTED
4989 #ifdef PNG_READ_PACKSWAP_SUPPORTED
4994 #ifdef PNG_READ_FILLER_SUPPORTED
5000 #ifdef PNG_READ_SWAP_ALPHA_SUPPORTED
5005 #ifdef PNG_READ_16BIT_SUPPORTED
5006 #ifdef PNG_READ_SWAP_SUPPORTED
5012 #ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
5016 (*(
png_ptr->read_user_transform_fn))
5026 #ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
5027 if (
png_ptr->user_transform_depth != 0)
5028 row_info->bit_depth =
png_ptr->user_transform_depth;
5030 if (
png_ptr->user_transform_channels != 0)
5031 row_info->channels =
png_ptr->user_transform_channels;
5033 row_info->pixel_depth = (png_byte)(row_info->bit_depth *
5034 row_info->channels);
5036 row_info->rowbytes =
PNG_ROWBYTES(row_info->pixel_depth, row_info->width);
#define PNG_BGR
Definition: pngpriv.h:642
#define PNG_SCALE_16_TO_8
Definition: pngpriv.h:669
const typedef png_byte * png_const_bytep
Definition: pngconf.h:580
static void png_do_chop(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2450
#define PNG_FP_MIN
Definition: png.h:659
#define PNG_QUANTIZE_BLUE_BITS
Definition: pnglibconf.h:202
#define PNG_16_TO_8
Definition: pngpriv.h:652
#define PNG_QUANTIZE_GREEN_BITS
Definition: pnglibconf.h:203
#define PNG_EXPAND
Definition: pngpriv.h:654
void PNGFAPI png_set_background_fixed(png_structrp png_ptr, png_const_color_16p background_color, int background_gamma_code, int need_expand, png_fixed_point background_gamma)
Definition: pngrtran.c:137
#define PNG_GAMMA_MAC_18
Definition: png.h:1148
png_fixed_point png_reciprocal(png_fixed_point a)
Definition: png.c:3488
#define PNG_UNUSED(param)
Definition: pngpriv.h:438
struct png_dsort_struct * next
Definition: pngrtran.c:420
void png_build_gamma_table(png_structrp png_ptr, int bit_depth)
Definition: png.c:4196
#define PNG_DEFAULT_sRGB
Definition: png.h:1147
#define PNG_INVERT_ALPHA
Definition: pngpriv.h:661
static void png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
Definition: pngrtran.c:3944
#define PNG_CRC_ERROR_QUIT
Definition: png.h:1437
png_fixed_point png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
Definition: png.c:3316
png_structrp int error_action
Definition: png.h:1083
static int png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma)
Definition: pngrtran.c:1092
#define PNG_BACKGROUND_EXPAND
Definition: pngpriv.h:650
void PNGAPI png_free(png_const_structrp png_ptr, png_voidp ptr)
Definition: pngmem.c:232
#define PNG_COLOR_DIST(c1, c2)
Definition: pngpriv.h:722
static png_fixed_point convert_gamma_value(png_structrp png_ptr, double output_gamma)
Definition: pngrtran.c:262
struct png_dsort_struct png_dsort
#define PNG_RGB_TO_GRAY_ERR
Definition: pngpriv.h:663
#define PNG_GAMMA_sRGB
Definition: png.h:1149
#define PNG_GRAY_TO_RGB
Definition: pngpriv.h:656
#define PNG_BACKGROUND_GAMMA_UNIQUE
Definition: png.h:1310
#define PNG_COMPOSE
Definition: pngpriv.h:649
#define PNG_READ_ALPHA_MODE_SUPPORTED
Definition: pnglibconf.h:50
#define PNG_FLAG_ROW_INIT
Definition: pngpriv.h:685
#define PNG_EXPAND_tRNS
Definition: pngpriv.h:668
png_byte * png_bytep
Definition: pngconf.h:579
uint8_t i
Definition: screen_test_graph.c:72
#define PNG_ALPHA_ASSOCIATED
Definition: png.h:1132
static void png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2571
static void png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
Definition: pngrtran.c:4145
png_uint_16 png_gamma_correct(png_structrp png_ptr, unsigned int value, png_fixed_point gamma_val)
Definition: png.c:3947
#define PNG_INVERT_MONO
Definition: pngpriv.h:647
#define PNG_ERROR_ACTION_WARN
Definition: png.h:1077
#define PNG_READ_FILLER_SUPPORTED
Definition: pnglibconf.h:59
#define PNG_COLOR_TYPE_RGB_ALPHA
Definition: png.h:671
#define PNG_GAMMA_MAC_OLD
Definition: pngpriv.h:904
#define PNG_FLAG_ASSUME_sRGB
Definition: pngpriv.h:691
png_structrp png_const_color_16p int int need_expand
Definition: png.h:1302
#define PNG_FLAG_CRC_CRITICAL_IGNORE
Definition: pngpriv.h:690
#define PNG_GAMMA_MAC_INVERSE
Definition: pngpriv.h:905
static void png_do_unpack(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2152
static void png_init_palette_transformations(png_structrp png_ptr)
Definition: pngrtran.c:1117
#define PNG_CRC_NO_CHANGE
Definition: png.h:1441
#define NULL
Definition: usbd_def.h:53
png_uint_32 width
Definition: png.h:756
png_dsort ** png_dsortpp
Definition: pngrtran.c:425
#define PNG_READ_STRIP_ALPHA_SUPPORTED
Definition: pnglibconf.h:75
png_structrp png_ptr
Definition: png.h:1083
png_dsort * png_dsortp
Definition: pngrtran.c:424
#define PNG_COLOR_TYPE_RGB
Definition: png.h:670
png_const_structrp png_const_inforp info_ptr
Definition: png.h:1939
png_byte right
Definition: pngrtran.c:422
static png_fixed_point translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, int is_screen)
Definition: pngrtran.c:223
void png_do_invert(png_row_infop row_info, png_bytep row)
Definition: pngtrans.c:262
#define PNG_SWAP_BYTES
Definition: pngpriv.h:646
void png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
Definition: pngtrans.c:699
void png_do_bgr(png_row_infop row_info, png_bytep row)
Definition: pngtrans.c:619
unsigned int png_uint_32
Definition: pngconf.h:511
png_uint_16(PNGAPI png_get_uint_16)(png_const_bytep buf)
Definition: pngrutil.c:102
#define PNG_RGB_TO_GRAY_WARN
Definition: pngpriv.h:664
#define PNG_ALPHA_PNG
Definition: png.h:1130
static void png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2475
#define PNG_HAVE_IHDR
Definition: png.h:644
#define PNG_PACKSWAP
Definition: pngpriv.h:658
#define PNG_FLAG_CRC_ANCILLARY_USE
Definition: pngpriv.h:687
png_structrp int png_fixed_point red
Definition: png.h:1083
png_byte channels
Definition: png.h:760
#define PNG_BACKGROUND_IS_GRAY
Definition: pngpriv.h:635
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:668
const typedef png_uint_16p * png_const_uint_16pp
Definition: pngpriv.h:937
png_byte color_type
Definition: png.h:758
png_byte blue
Definition: png.h:482
#define png_debug(l, m)
Definition: pngdebug.h:145
static void png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
Definition: pngrtran.c:3200
png_byte green
Definition: png.h:481
#define PNG_CRC_WARN_DISCARD
Definition: png.h:1438
#define PNG_FLAG_DETECT_UNINITIALIZED
Definition: pngpriv.h:693
png_byte png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
Definition: png.c:3864
#define PNG_FILLER
Definition: pngpriv.h:657
int png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, png_int_32 divisor)
Definition: png.c:3349
png_int_32 png_fixed_point
Definition: pngconf.h:574
#define PNG_QUANTIZE_RED_BITS
Definition: pnglibconf.h:204
#define PNG_ERROR_ACTION_ERROR
Definition: png.h:1078
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
#define PNG_CRC_DEFAULT
Definition: png.h:1436
list a
Definition: createSpeedLookupTable.py:29
png_byte pixel_depth
Definition: png.h:761
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
Definition: pnglibconf.h:71
#define PNG_ADD_ALPHA
Definition: pngpriv.h:667
void png_do_swap(png_row_infop row_info, png_bytep row)
Definition: pngtrans.c:319
#define PNG_ALPHA_OPTIMIZED
Definition: png.h:1134
#define png_composite(composite, fg, alpha, bg)
Definition: png.h:2510
Definition: pngrtran.c:418
png_uint_16 ** png_uint_16pp
Definition: pngconf.h:609
void png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
Definition: png.c:2469
#define PNG_RGB_TO_GRAY
Definition: pngpriv.h:665
#define PNG_CRC_QUIET_USE
Definition: png.h:1440
#define PNG_FLAG_CRC_CRITICAL_USE
Definition: pngpriv.h:689
#define PNG_BACKGROUND_GAMMA_UNKNOWN
Definition: png.h:1307
else png_error(png_ptr, "png_image_write_to_memory: PNG too big")
static void png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2389
png_fixed_point png_reciprocal2(png_fixed_point a, png_fixed_point b)
Definition: png.c:3543
png_structrp png_const_color_16p int background_gamma_code
Definition: png.h:1302
#define PNG_BACKGROUND_GAMMA_SCREEN
Definition: png.h:1308
static void png_do_expand_16(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:4609
static void png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info, png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)
Definition: pngrtran.c:4209
#define PNG_ERROR_ACTION_NONE
Definition: png.h:1076
size_t png_alloc_size_t
Definition: pngconf.h:557
#define PNG_FLAG_CRC_ANCILLARY_NOWARN
Definition: pngpriv.h:688
void png_do_packswap(png_row_infop row_info, png_bytep row)
Definition: pngtrans.c:455
static void png_do_read_filler(png_row_infop row_info, png_bytep row, png_uint_32 filler, png_uint_32 flags)
Definition: pngrtran.c:2673
#define PNG_SHIFT
Definition: pngpriv.h:645
png_structrp png_fixed_point screen_gamma
Definition: png.h:1352
#define PNG_BACKGROUND_GAMMA_FILE
Definition: png.h:1309
#define PNG_ROWBYTES(pixel_bits, width)
Definition: pngpriv.h:738
void PNGFAPI png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)
Definition: pngrtran.c:970
#define PNG_FLAG_FILLER_AFTER
Definition: pngpriv.h:686
static void png_do_quantize(png_row_infop row_info, png_bytep row, png_const_bytep palette_lookup, png_const_bytep quantize_lookup)
Definition: pngrtran.c:4639
static int png_rtran_ok(png_structrp png_ptr, int need_IHDR)
Definition: pngrtran.c:110
#define PNG_COLOR_MASK_COLOR
Definition: png.h:664
#define PNG_ALPHA_BROKEN
Definition: png.h:1135
void PNGFAPI png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, png_fixed_point file_gamma)
Definition: pngrtran.c:818
static void png_do_unshift(png_row_infop row_info, png_bytep row, png_const_color_8p sig_bits)
Definition: pngrtran.c:2250
png_byte red
Definition: png.h:480
int
Definition: createSpeedLookupTable.py:15
int png_gamma_significant(png_fixed_point gamma_val)
Definition: png.c:3509
#define PNG_READ_BACKGROUND_SUPPORTED
Definition: pnglibconf.h:52
#define png_composite_16(composite, fg, alpha, bg)
Definition: png.h:2519
#define PNG_FLAG_CRC_CRITICAL_MASK
Definition: pngpriv.h:714
#define PNG_PACK
Definition: pngpriv.h:644
#define PNG_FLAG_OPTIMIZE_ALPHA
Definition: pngpriv.h:692
#define PNG_FLAG_CRC_ANCILLARY_MASK
Definition: pngpriv.h:711
#define PNG_COLOR_MASK_PALETTE
Definition: png.h:663
void PNGFAPI png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, png_fixed_point output_gamma)
Definition: pngrtran.c:287
static void png_init_rgb_transformations(png_structrp png_ptr)
Definition: pngrtran.c:1206
#define PNG_QUANTIZE
Definition: pngpriv.h:648
png_structrp png_const_color_16p background_color
Definition: png.h:1302
static void png_do_expand(png_row_infop row_info, png_bytep row, png_const_color_16p trans_color)
Definition: pngrtran.c:4379
#define PNG_STRIP_ALPHA
Definition: pngpriv.h:660
#define PNG_FP_MAX
Definition: png.h:658
#define PNG_GAMMA
Definition: pngpriv.h:655
png_structrp int mode
Definition: png.h:1139
#define PNG_FP_1
Definition: png.h:656
void png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:392
size_t rowbytes
Definition: png.h:757
static void png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2860
void png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:405
#define PNG_CRC_WARN_USE
Definition: png.h:1439
list b
Definition: createSpeedLookupTable.py:30
png_byte bit_depth
Definition: png.h:759
#define PNG_ENCODE_ALPHA
Definition: pngpriv.h:666
#define PNG_COLOR_TYPE_GRAY_ALPHA
Definition: png.h:672
#define PNG_GAMMA_sRGB_INVERSE
Definition: pngpriv.h:906
void PNGAPI png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr)
Definition: pngrtran.c:914
void PNGAPI png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
Definition: pngerror.c:216
png_int_32(PNGAPI png_get_int_32)(png_const_bytep buf)
Definition: pngrutil.c:84
#define PNG_EXPAND_16
Definition: pngpriv.h:651
#define PNG_COLOR_MASK_ALPHA
Definition: png.h:665
png_byte left
Definition: pngrtran.c:421
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:669
#define PNG_SWAP_ALPHA
Definition: pngpriv.h:659
static int png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
Definition: pngrtran.c:2999
#define PNG_USER_TRANSFORM
Definition: pngpriv.h:662
void png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
Definition: pngtrans.c:495