2066 const png_uint_32 output_format = image->
format;
2070 unsigned int cmap_entries;
2071 unsigned int output_processing;
2072 unsigned int data_encoding =
P_NOTSET;
2077 unsigned int background_index = 256;
2078 png_uint_32 back_r, back_g, back_b;
2081 int expand_tRNS = 0;
2093 back_b = back_g = back_r = 0;
2097 "a background color must be supplied to remove alpha/transparency");
2112 back_b = back_r = back_g;
2116 else if (output_encoding ==
P_LINEAR)
2117 back_b = back_r = back_g = 65535;
2120 back_b = back_r = back_g = 255;
2127 if ((png_ptr->colorspace.
flags & PNG_COLORSPACE_HAVE_GAMMA) == 0)
2141 png_ptr->colorspace.
flags |= PNG_COLORSPACE_HAVE_GAMMA;
2157 unsigned int step,
i, val, trans = 256, back_alpha = 0;
2159 cmap_entries = 1U << png_ptr->
bit_depth;
2161 png_error(png_ptr,
"gray[8] color-map: too few entries");
2163 step = 255 / (cmap_entries - 1);
2171 trans = png_ptr->trans_color.gray;
2174 back_alpha = output_encoding ==
P_LINEAR ? 65535 : 255;
2184 for (i=val=0; i<cmap_entries; ++
i, val += step)
2204 back_alpha, output_encoding);
2240 png_error(png_ptr,
"gray[16] color-map: too few entries");
2246 unsigned int back_alpha;
2253 if (back_r == back_g && back_g == back_b)
2259 png_uint_32 gray = back_g;
2290 back_alpha = output_encoding ==
P_LINEAR ? 65535 : 255;
2302 background_index = 254;
2308 back_alpha, output_encoding);
2329 if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
2332 png_error(png_ptr,
"gray+alpha color-map: too few entries");
2359 (back_r == back_g && back_g == back_b))
2363 png_uint_32 gray = back_g;
2366 png_error(png_ptr,
"gray-alpha color-map: too few entries");
2400 png_error(png_ptr,
"ga-alpha color-map: too few entries");
2405 png_uint_32 gray = (i * 256 + 115) / 231;
2413 background_index =
i;
2415 output_encoding ==
P_LINEAR ? 65535U : 255U, output_encoding);
2425 if (output_encoding ==
P_sRGB)
2443 png_uint_32 alpha = 51 *
a;
2444 png_uint_32 back_rx = (255-alpha) * back_r;
2445 png_uint_32 back_gx = (255-alpha) * back_g;
2446 png_uint_32 back_bx = (255-alpha) * back_b;
2470 if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0)
2489 (output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
2498 png_error(png_ptr,
"rgb[ga] color-map: too few entries");
2512 png_error(png_ptr,
"rgb[gray] color-map: too few entries");
2539 png_uint_32 gray = back_g;
2546 if (data_encoding ==
P_FILE)
2553 if (output_encoding ==
P_sRGB)
2557 png_ptr->colorspace.gamma));
2563 back_g, 0, output_encoding);
2566 else if (output_encoding ==
P_LINEAR)
2612 if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0)
2617 png_error(png_ptr,
"rgb+alpha color-map: too few entries");
2628 background_index = cmap_entries++;
2631 for (r=0; r<256; r = (r << 1) | 0x7f)
2635 for (g=0; g<256; g = (g << 1) | 0x7f)
2642 for (b=0; b<256; b = (b << 1) | 0x7f)
2661 unsigned int sample_size =
2663 png_uint_32 r, g,
b;
2666 png_error(png_ptr,
"rgb-alpha color-map: too few entries");
2671 back_g, back_b, 0, output_encoding);
2693 sample_size * cmap_entries,
2699 background_index = cmap_entries++;
2704 for (r=0; r<256; r = (r << 1) | 0x7f)
2706 for (g=0; g<256; g = (g << 1) | 0x7f)
2711 for (b=0; b<256; b = (b << 1) | 0x7f)
2714 back_r, output_encoding),
2716 back_g, output_encoding),
2718 back_b, output_encoding),
2719 0, output_encoding);
2732 c.
red = (png_uint_16)back_r;
2734 c.
blue = (png_uint_16)back_b;
2751 png_error(png_ptr,
"rgb color-map: too few entries");
2764 unsigned int num_trans = png_ptr->
num_trans;
2767 const int do_background = trans != NULL &&
2778 if (cmap_entries > 256)
2782 png_error(png_ptr,
"palette color-map: too few entries");
2784 for (i=0; i < cmap_entries; ++
i)
2786 if (do_background != 0 && i < num_trans && trans[i] < 255)
2790 back_b, 0, output_encoding);
2799 trans[i], back_r, output_encoding),
2801 trans[i], back_g, output_encoding),
2803 trans[i], back_b, output_encoding),
2804 output_encoding ==
P_LINEAR ? trans[i] * 257U :
2812 colormap[i].green, colormap[i].blue,
2813 i < num_trans ? trans[i] : 255U,
P_FILE);
2825 png_error(png_ptr,
"invalid PNG color type");
2831 if (expand_tRNS != 0 && png_ptr->
num_trans > 0 &&
2835 switch (data_encoding)
2838 png_error(png_ptr,
"bad data option (internal error)");
2853 png_error(png_ptr,
"color map overflow (BAD internal error)");
2858 switch (output_processing)
2862 goto bad_background;
2867 goto bad_background;
2871 if (background_index >= cmap_entries ||
2873 goto bad_background;
2878 goto bad_background;
2883 goto bad_background;
2887 png_error(png_ptr,
"bad processing option (internal error)");
2890 png_error(png_ptr,
"bad background index (internal error)");
#define PNG_sRGB_FROM_LINEAR(linear)
Definition: pngpriv.h:853
int colormap_processing
Definition: pngread.c:1272
uint8_t image[110000000]
Definition: gige_snap.cpp:38
#define PNG_CMAP_RGB
Definition: pngread.c:1248
#define PNG_IMAGE_SAMPLE_SIZE(fmt)
Definition: png.h:2989
#define PNG_GRAY_COLORMAP_ENTRIES
Definition: pngread.c:1972
static int make_gray_colormap(png_image_read_control *display)
Definition: pngread.c:1963
#define PNG_BACKGROUND_GAMMA_SCREEN
Definition: png.h:1446
png_controlp opaque
Definition: png.h:2809
int i
Definition: rw_test.cpp:37
#define PNG_CMAP_GA_BACKGROUND
Definition: pngread.c:1253
#define P_sRGB
Definition: pngread.c:1237
#define PNG_COLOR_TYPE_RGB
Definition: png.h:811
#define PNG_COLOR_TYPE_GRAY_ALPHA
Definition: png.h:813
png_uint_16 blue
Definition: png.h:634
#define PNG_COLOR_TYPE_PALETTE
Definition: png.h:810
png_uint_16 gray
Definition: png.h:635
#define PNG_CMAP_RGB_BACKGROUND
Definition: pngread.c:1255
png_byte red
Definition: png.h:621
png_uint_32 flags
Definition: png.h:2814
Definition: pngstruct.h:144
#define PNG_COLOR_TYPE_RGB_ALPHA
Definition: png.h:812
png_voidp colormap
Definition: pngread.c:1264
#define png_voidcast(type, value)
Definition: pngpriv.h:408
Definition: pngread.c:1258
static int make_gray_file_colormap(png_image_read_control *display)
Definition: pngread.c:1952
png_const_colorp background
Definition: pngread.c:1265
long b
Definition: jpegint.h:371
png_byte color_type
Definition: pngstruct.h:252
#define PNG_CMAP_TRANS_BACKGROUND
Definition: pngread.c:1254
PNG_IMPEXP void() png_set_packing(png_structrp png_ptr)
Definition: pngtrans.c:50
static int png_gamma_not_sRGB(png_fixed_point g)
Definition: pngread.c:1363
PNG_IMPEXP void() png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, png_fixed_point red, png_fixed_point green)
Definition: pngrtran.c:953
png_uint_32 format
Definition: png.h:2813
png_uint_16 green
Definition: png.h:633
#define P_FILE
Definition: pngread.c:1239
#define PNG_ALPHA_PNG
Definition: png.h:1268
png_colorp palette
Definition: pngstruct.h:238
static int make_ga_colormap(png_image_read_control *display)
Definition: pngread.c:1975
png_imagep image
Definition: pngread.c:1261
png_uint_32 flags
Definition: pngstruct.h:180
#define PNG_COLOR_TYPE_GRAY
Definition: png.h:809
const png_byte * png_const_bytep
Definition: pngconf.h:601
static png_uint_32 png_colormap_compose(png_image_read_control *display, png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha, png_uint_32 background, int encoding)
Definition: pngread.c:1697
PNG_IMPEXP void() png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, png_fixed_point output_gamma)
Definition: pngrtran.c:275
png_uint_16 num_palette
Definition: pngstruct.h:239
#define PNG_CMAP_NONE
Definition: pngread.c:1245
#define PNG_ERROR_ACTION_NONE
Definition: png.h:1214
#define P_LINEAR
Definition: pngread.c:1238
#define PNG_GAMMA_sRGB
Definition: png.h:1287
png_structp png_ptr
Definition: pngpriv.h:1867
#define PNG_GA_COLORMAP_ENTRIES
Definition: pngread.c:2027
Definition: eci2kep_test.cpp:33
#define PNG_IMAGE_FLAG_16BIT_sRGB
Definition: png.h:3080
static int make_rgb_colormap(png_image_read_control *display)
Definition: pngread.c:2030
png_byte bit_depth
Definition: pngstruct.h:253
png_byte index
Definition: png.h:631
PNG_IMPEXP void() png_set_scale_16(png_structrp png_ptr)
Definition: pngrtran.c:171
#define PNG_COLOR_MASK_ALPHA
Definition: png.h:806
#define PNG_CMAP_NONE_BACKGROUND
Definition: pngread.c:1252
#define PNG_CMAP_TRANS
Definition: pngread.c:1247
#define PNG_CMAP_GA
Definition: pngread.c:1246
png_uint_16 num_trans
Definition: pngstruct.h:246
PNG_IMPEXP void() 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:125
#define PNG_DIV257(v16)
Definition: pngpriv.h:657
PNG_IMPEXP void() png_error(png_const_structrp png_ptr, png_const_charp error_message)
Definition: pngerror.c:40
#define PNG_GAMMA_LINEAR
Definition: png.h:1288
#define PNG_FORMAT_FLAG_LINEAR
Definition: png.h:2915
#define PNG_FORMAT_FLAG_COLOR
Definition: png.h:2914
#define P_NOTSET
Definition: pngread.c:1236
png_uint_32 colormap_entries
Definition: png.h:2815
png_uint_16 red
Definition: png.h:632
#define PNG_RGB_INDEX(r, g, b)
Definition: pngread.c:2055
PNG_IMPEXP void() png_set_tRNS_to_alpha(png_structrp png_ptr)
Definition: pngrtran.c:909
const png_uint_16 png_sRGB_table[256]
Definition: png.c:4258
static void png_create_colormap_entry(png_image_read_control *display, png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue, png_uint_32 alpha, int encoding)
Definition: pngread.c:1734
#define PNG_CMAP_RGB_ALPHA
Definition: pngread.c:1249
#define PNG_FORMAT_FLAG_ALPHA
Definition: png.h:2913
png_uint_16 png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)
Definition: png.c:3800
#define PNG_RGB_COLORMAP_ENTRIES
Definition: pngread.c:2052
#define PNG_GAMMA_sRGB_INVERSE
Definition: pngpriv.h:807
png_byte green
Definition: png.h:622
png_byte blue
Definition: png.h:623
#define PNG_CMAP_RGB_ALPHA_BACKGROUND
Definition: pngread.c:1256