mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from libpng-0.85.tar
This commit is contained in:
committed by
Glenn Randers-Pehrson
parent
0f71645dfe
commit
6d76471acd
379
pngrtran.c
379
pngrtran.c
@@ -1,10 +1,10 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for png readers
|
||||
|
||||
libpng 1.0 beta 2 - version 0.8
|
||||
libpng 1.0 beta 2 - version 0.85
|
||||
For conditions of distribution and use, see copyright notice in png.h
|
||||
Copyright (c) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
August 20, 1995
|
||||
December 19, 1995
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL
|
||||
@@ -13,8 +13,8 @@
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
/* handle alpha and tRNS via a background color */
|
||||
void
|
||||
png_set_background(png_struct *png_ptr,
|
||||
png_color_16 *background_color, int background_gamma_code,
|
||||
png_set_background(png_structp png_ptr,
|
||||
png_color_16p background_color, int background_gamma_code,
|
||||
int need_expand, double background_gamma)
|
||||
{
|
||||
png_ptr->transformations |= PNG_BACKGROUND;
|
||||
@@ -29,7 +29,7 @@ png_set_background(png_struct *png_ptr,
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
/* strip 16 bit depth files to 8 bit depth */
|
||||
void
|
||||
png_set_strip_16(png_struct *png_ptr)
|
||||
png_set_strip_16(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->transformations |= PNG_16_TO_8;
|
||||
}
|
||||
@@ -42,16 +42,19 @@ png_set_strip_16(png_struct *png_ptr)
|
||||
is greater then the maximum number, the palette will be
|
||||
modified to fit in the maximum number */
|
||||
|
||||
typedef struct dsort_struct
|
||||
|
||||
typedef struct png_dsort_struct
|
||||
{
|
||||
struct dsort_struct *next;
|
||||
struct png_dsort_struct FAR * next;
|
||||
png_byte left;
|
||||
png_byte right;
|
||||
} dsort;
|
||||
} png_dsort;
|
||||
typedef png_dsort FAR * png_dsortp;
|
||||
typedef png_dsort FAR * FAR * png_dsortpp;
|
||||
|
||||
void
|
||||
png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
int num_palette, int maximum_colors, png_uint_16 *histogram,
|
||||
png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
int num_palette, int maximum_colors, png_uint_16p histogram,
|
||||
int full_dither)
|
||||
{
|
||||
png_ptr->transformations |= PNG_DITHER;
|
||||
@@ -60,7 +63,7 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
{
|
||||
int i;
|
||||
|
||||
png_ptr->dither_index = png_malloc(png_ptr,
|
||||
png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
|
||||
num_palette * sizeof (png_byte));
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->dither_index[i] = i;
|
||||
@@ -74,10 +77,10 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
perhaps not the best solution, but good enough */
|
||||
|
||||
int i;
|
||||
png_byte *sort;
|
||||
png_bytep sort;
|
||||
|
||||
/* initialize an array to sort colors */
|
||||
sort = (png_byte *)png_malloc(png_ptr, num_palette * sizeof (png_byte));
|
||||
sort = (png_bytep)png_malloc(png_ptr, num_palette * sizeof (png_byte));
|
||||
|
||||
/* initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@@ -200,16 +203,16 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
int i;
|
||||
int max_d;
|
||||
int num_new_palette;
|
||||
dsort **hash;
|
||||
png_byte *index_to_palette;
|
||||
png_dsortpp hash;
|
||||
png_bytep index_to_palette;
|
||||
/* where the original index currently is in the palette */
|
||||
png_byte *palette_to_index;
|
||||
png_bytep palette_to_index;
|
||||
/* which original index points to this palette color */
|
||||
|
||||
/* initialize palette index arrays */
|
||||
index_to_palette = (png_byte *)png_malloc(png_ptr,
|
||||
index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||
num_palette * sizeof (png_byte));
|
||||
palette_to_index = (png_byte *)png_malloc(png_ptr,
|
||||
palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||
num_palette * sizeof (png_byte));
|
||||
|
||||
/* initialize the sort array */
|
||||
@@ -219,10 +222,10 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
palette_to_index[i] = i;
|
||||
}
|
||||
|
||||
hash = (dsort **)png_malloc(png_ptr, 769 * sizeof (dsort *));
|
||||
hash = (png_dsortpp)png_malloc(png_ptr, 769 * sizeof (png_dsortp));
|
||||
for (i = 0; i < 769; i++)
|
||||
hash[i] = (dsort *)0;
|
||||
/* png_memset(hash, 0, 769 * sizeof (dsort *)); */
|
||||
hash[i] = (png_dsortp)0;
|
||||
/* png_memset(hash, 0, 769 * sizeof (png_dsortp)); */
|
||||
|
||||
num_new_palette = num_palette;
|
||||
|
||||
@@ -246,13 +249,13 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
{
|
||||
int d;
|
||||
|
||||
d = PNG_COLOR_DIST(palette[i], palette[j]);
|
||||
d = PNG_COLOR_DIST(palette[i], palette[j]);
|
||||
|
||||
if (d <= max_d)
|
||||
{
|
||||
dsort *t;
|
||||
png_dsortp t;
|
||||
|
||||
t = png_malloc(png_ptr, sizeof (dsort));
|
||||
t = png_malloc(png_ptr, sizeof (png_dsort));
|
||||
t->next = hash[d];
|
||||
t->left = i;
|
||||
t->right = j;
|
||||
@@ -265,7 +268,7 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
{
|
||||
if (hash[i])
|
||||
{
|
||||
dsort *p;
|
||||
png_dsortp p;
|
||||
|
||||
for (p = hash[i]; p; p = p->next)
|
||||
{
|
||||
@@ -325,12 +328,12 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
{
|
||||
if (hash[i])
|
||||
{
|
||||
dsort *p;
|
||||
png_dsortp p;
|
||||
|
||||
p = hash[i];
|
||||
while (p)
|
||||
{
|
||||
dsort *t;
|
||||
png_dsortp t;
|
||||
|
||||
t = p->next;
|
||||
png_free(png_ptr, p);
|
||||
@@ -348,7 +351,7 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
num_palette = maximum_colors;
|
||||
}
|
||||
if (!(png_ptr->palette))
|
||||
{
|
||||
{
|
||||
png_ptr->palette = palette;
|
||||
png_ptr->user_palette = 1;
|
||||
}
|
||||
@@ -359,22 +362,22 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
int i;
|
||||
int total_bits, num_red, num_green, num_blue;
|
||||
png_uint_32 num_entries;
|
||||
png_bytef *distance;
|
||||
png_bytep distance;
|
||||
|
||||
total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS +
|
||||
PNG_DITHER_BLUE_BITS;
|
||||
PNG_DITHER_BLUE_BITS;
|
||||
|
||||
num_red = (1 << PNG_DITHER_RED_BITS);
|
||||
num_green = (1 << PNG_DITHER_GREEN_BITS);
|
||||
num_blue = (1 << PNG_DITHER_BLUE_BITS);
|
||||
num_blue = (1 << PNG_DITHER_BLUE_BITS);
|
||||
num_entries = ((png_uint_32)1 << total_bits);
|
||||
|
||||
png_ptr->palette_lookup = (png_bytef *)png_large_malloc(png_ptr,
|
||||
png_ptr->palette_lookup = (png_bytep )png_large_malloc(png_ptr,
|
||||
(png_size_t)num_entries * sizeof (png_byte));
|
||||
|
||||
png_memset(png_ptr->palette_lookup, 0, (png_size_t)num_entries * sizeof (png_byte));
|
||||
|
||||
distance = (png_bytef *)png_large_malloc(png_ptr,
|
||||
distance = (png_bytep )png_large_malloc(png_ptr,
|
||||
(png_size_t)num_entries * sizeof (png_byte));
|
||||
|
||||
png_memset(distance, 0xff, (png_size_t)num_entries * sizeof (png_byte));
|
||||
@@ -384,7 +387,7 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
int r, g, b, ir, ig, ib;
|
||||
|
||||
r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS));
|
||||
g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS));
|
||||
g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS));
|
||||
b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS));
|
||||
|
||||
for (ir = 0; ir < num_red; ir++)
|
||||
@@ -402,7 +405,7 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
dm = ((dr > dg) ? dr : dg);
|
||||
index_g = index_r | (ig << PNG_DITHER_BLUE_BITS);
|
||||
for (ib = 0; ib < num_blue; ib++)
|
||||
{
|
||||
{
|
||||
int index, db, dmax, d;
|
||||
|
||||
index = index_g | ib;
|
||||
@@ -420,7 +423,7 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
}
|
||||
}
|
||||
|
||||
png_large_free(png_ptr, distance);
|
||||
png_large_free(png_ptr, distance);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -428,7 +431,7 @@ png_set_dither(png_struct *png_ptr, png_color *palette,
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
/* transform the image from the file_gamma to the screen_gamma */
|
||||
void
|
||||
png_set_gamma(png_struct *png_ptr, double screen_gamma,
|
||||
png_set_gamma(png_structp png_ptr, double screen_gamma,
|
||||
double file_gamma)
|
||||
{
|
||||
png_ptr->transformations |= PNG_GAMMA;
|
||||
@@ -442,7 +445,7 @@ png_set_gamma(png_struct *png_ptr, double screen_gamma,
|
||||
less then 8 bit depth to 8 bit depth, and expand tRNS chunks
|
||||
to alpha channels */
|
||||
void
|
||||
png_set_expand(png_struct *png_ptr)
|
||||
png_set_expand(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->transformations |= PNG_EXPAND;
|
||||
}
|
||||
@@ -450,7 +453,7 @@ png_set_expand(png_struct *png_ptr)
|
||||
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
void
|
||||
png_set_gray_to_rgb(png_struct *png_ptr)
|
||||
png_set_gray_to_rgb(png_structp png_ptr)
|
||||
{
|
||||
png_ptr->transformations |= PNG_GRAY_TO_RGB;
|
||||
}
|
||||
@@ -459,7 +462,7 @@ png_set_gray_to_rgb(png_struct *png_ptr)
|
||||
/* initialize everything needed for the read. This includes modifying
|
||||
the palette */
|
||||
void
|
||||
png_init_read_transformations(png_struct *png_ptr)
|
||||
png_init_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
int color_type;
|
||||
|
||||
@@ -474,7 +477,7 @@ png_init_read_transformations(png_struct *png_ptr)
|
||||
(png_ptr->transformations & PNG_BACKGROUND) &&
|
||||
png_ptr->background_expand)
|
||||
/* (!(png_ptr->transformations & PNG_BACKGROUND) ||
|
||||
png_ptr->background_expand)) */
|
||||
png_ptr->background_expand)) */
|
||||
{
|
||||
/* expand background chunk. While this may not be
|
||||
the fastest way to do this, it only happens once
|
||||
@@ -492,7 +495,7 @@ png_init_read_transformations(png_struct *png_ptr)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
(png_ptr->transformations & PNG_BACKGROUND) &&
|
||||
png_ptr->background_expand)
|
||||
{
|
||||
@@ -523,12 +526,12 @@ png_init_read_transformations(png_struct *png_ptr)
|
||||
{
|
||||
double g, gs, m;
|
||||
|
||||
m = (double)((png_uint_32)1 << png_ptr->bit_depth);
|
||||
m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1);
|
||||
g = 1.0;
|
||||
gs = 1.0;
|
||||
|
||||
switch (png_ptr->background_gamma_type)
|
||||
{
|
||||
{
|
||||
case PNG_BACKGROUND_GAMMA_SCREEN:
|
||||
g = (png_ptr->display_gamma);
|
||||
gs = 1.0;
|
||||
@@ -544,9 +547,9 @@ png_init_read_transformations(png_struct *png_ptr)
|
||||
break;
|
||||
}
|
||||
|
||||
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
if (color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
png_ptr->background_1.red = (png_uint_16)(pow(
|
||||
png_ptr->background_1.red = (png_uint_16)(pow(
|
||||
(double)png_ptr->background.red / m, g) * m + .5);
|
||||
png_ptr->background_1.green = (png_uint_16)(pow(
|
||||
(double)png_ptr->background.green / m, g) * m + .5);
|
||||
@@ -562,9 +565,9 @@ png_init_read_transformations(png_struct *png_ptr)
|
||||
else
|
||||
{
|
||||
png_ptr->background_1.gray = (png_uint_16)(pow(
|
||||
(double)png_ptr->background.gray / m, g) * m + .5);
|
||||
(double)png_ptr->background.gray / m, g) * m + .5);
|
||||
png_ptr->background.gray = (png_uint_16)(pow(
|
||||
(double)png_ptr->background.gray / m, gs) * m + .5);
|
||||
(double)png_ptr->background.gray / m, gs) * m + .5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -572,9 +575,9 @@ png_init_read_transformations(png_struct *png_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) && defined(PNG_READ_sBIT_SUPPORTED)
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_SHIFT) &&
|
||||
png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
png_uint_16 i;
|
||||
int sr, sg, sb;
|
||||
@@ -582,7 +585,7 @@ png_init_read_transformations(png_struct *png_ptr)
|
||||
sr = 8 - png_ptr->sig_bit.red;
|
||||
if (sr < 0 || sr > 8)
|
||||
sr = 0;
|
||||
sg = 8 - png_ptr->sig_bit.green;
|
||||
sg = 8 - png_ptr->sig_bit.green;
|
||||
if (sg < 0 || sg > 8)
|
||||
sg = 0;
|
||||
sb = 8 - png_ptr->sig_bit.blue;
|
||||
@@ -600,9 +603,9 @@ png_init_read_transformations(png_struct *png_ptr)
|
||||
|
||||
/* modify the info structure to reflect the transformations. The
|
||||
info should be updated so a png file could be written with it,
|
||||
assuming the transformations result in valid png data */
|
||||
assuming the transformations result in valid png data */
|
||||
void
|
||||
png_read_transform_info(png_struct *png_ptr, png_info *info_ptr)
|
||||
png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_EXPAND) &&
|
||||
@@ -618,7 +621,7 @@ png_read_transform_info(png_struct *png_ptr, png_info *info_ptr)
|
||||
else if (png_ptr->transformations & PNG_EXPAND)
|
||||
{
|
||||
if (png_ptr->num_trans)
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
|
||||
if (info_ptr->bit_depth < 8)
|
||||
info_ptr->bit_depth = 8;
|
||||
info_ptr->num_trans = 0;
|
||||
@@ -636,7 +639,7 @@ png_read_transform_info(png_struct *png_ptr, png_info *info_ptr)
|
||||
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) && info_ptr->bit_depth == 16)
|
||||
info_ptr->bit_depth = 8;
|
||||
info_ptr->bit_depth = 8;
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
@@ -661,7 +664,7 @@ png_read_transform_info(png_struct *png_ptr, png_info *info_ptr)
|
||||
!(info_ptr->color_type & PNG_COLOR_MASK_COLOR))
|
||||
info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
|
||||
#endif
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
info_ptr->channels = 1;
|
||||
else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
info_ptr->channels = 3;
|
||||
@@ -677,7 +680,7 @@ png_read_transform_info(png_struct *png_ptr, png_info *info_ptr)
|
||||
and is very touchy. If you add a transformation, take care to
|
||||
decide how it fits in with the other transformations here */
|
||||
void
|
||||
png_do_read_transformations(png_struct *png_ptr)
|
||||
png_do_read_transformations(png_structp png_ptr)
|
||||
{
|
||||
#if defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_EXPAND) &&
|
||||
@@ -690,7 +693,7 @@ png_do_read_transformations(png_struct *png_ptr)
|
||||
{
|
||||
if (png_ptr->num_trans)
|
||||
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
&(png_ptr->trans_values));
|
||||
&(png_ptr->trans_values));
|
||||
else
|
||||
png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
|
||||
NULL);
|
||||
@@ -724,16 +727,16 @@ png_do_read_transformations(png_struct *png_ptr)
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_DITHER)
|
||||
{
|
||||
png_do_dither((png_row_info *)&(png_ptr->row_info),
|
||||
png_do_dither((png_row_infop)&(png_ptr->row_info),
|
||||
png_ptr->row_buf + 1,
|
||||
png_ptr->palette_lookup,
|
||||
png_ptr->palette_lookup,
|
||||
png_ptr->dither_index);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_INVERT_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_INVERT_MONO)
|
||||
png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED)
|
||||
@@ -744,7 +747,7 @@ png_do_read_transformations(png_struct *png_ptr)
|
||||
|
||||
#if defined(PNG_READ_PACK_SUPPORTED)
|
||||
if (png_ptr->transformations & PNG_PACK)
|
||||
png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_BGR_SUPPORTED)
|
||||
@@ -776,11 +779,11 @@ png_do_read_transformations(png_struct *png_ptr)
|
||||
the numbers 0 or 1. If you would rather they contain 0 and 255, use
|
||||
png_do_shift() after this. */
|
||||
void
|
||||
png_do_unpack(png_row_info *row_info, png_bytef *row)
|
||||
png_do_unpack(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
int shift;
|
||||
png_bytef *sp, *dp;
|
||||
png_uint_32 i;
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row && row_info && row_info->bit_depth < 8)
|
||||
{
|
||||
@@ -798,7 +801,7 @@ png_do_unpack(png_row_info *row_info, png_bytef *row)
|
||||
{
|
||||
shift = 0;
|
||||
sp--;
|
||||
}
|
||||
}
|
||||
else
|
||||
shift++;
|
||||
|
||||
@@ -831,7 +834,7 @@ png_do_unpack(png_row_info *row_info, png_bytef *row)
|
||||
{
|
||||
sp = row + (png_size_t)((row_info->width - 1) >> 1);
|
||||
dp = row + (png_size_t)row_info->width - 1;
|
||||
shift = (int)((1 - ((row_info->width + 1) & 1)) << 4);
|
||||
shift = (int)((1 - ((row_info->width + 1) & 1)) << 2);
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
*dp = (*sp >> shift) & 0xf;
|
||||
@@ -861,10 +864,10 @@ png_do_unpack(png_row_info *row_info, png_bytef *row)
|
||||
a row of bit depth 8, but only 5 are significant, this will shift
|
||||
the values back to 0 through 31 */
|
||||
void
|
||||
png_do_unshift(png_row_info *row_info, png_bytef *row,
|
||||
png_color_8 *sig_bits)
|
||||
png_do_unshift(png_row_infop row_info, png_bytep row,
|
||||
png_color_8p sig_bits)
|
||||
{
|
||||
png_bytef *bp;
|
||||
png_bytep bp;
|
||||
png_uint_16 value;
|
||||
png_uint_32 i;
|
||||
if (row && row_info && sig_bits &&
|
||||
@@ -876,34 +879,33 @@ png_do_unshift(png_row_info *row_info, png_bytef *row,
|
||||
channels = 0;
|
||||
if (row_info->color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->red < 0 ?
|
||||
0 : row_info->bit_depth - sig_bits->red;
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->green < 0 ?
|
||||
0 : row_info->bit_depth - sig_bits->green;
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->blue < 0 ?
|
||||
0 : row_info->bit_depth - sig_bits->blue;
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->red;
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->green;
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->gray < 0 ?
|
||||
0 : row_info->bit_depth - sig_bits->gray;
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->gray;
|
||||
}
|
||||
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
{
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->alpha < 0 ?
|
||||
0 : row_info->bit_depth - sig_bits->alpha;
|
||||
}
|
||||
shift[channels++] = row_info->bit_depth - sig_bits->alpha;
|
||||
}
|
||||
|
||||
value = 1;
|
||||
value = 0;
|
||||
|
||||
for (i = 0; i < channels; i++)
|
||||
{
|
||||
if (shift[i] != 0) value = 0;
|
||||
}
|
||||
for (i = 0; i < channels; i++)
|
||||
{
|
||||
if (shift[i] <= 0)
|
||||
shift[i] = 0;
|
||||
else
|
||||
value = 1;
|
||||
}
|
||||
|
||||
if (value == 1) return;
|
||||
if (!value)
|
||||
return;
|
||||
|
||||
switch (row_info->bit_depth)
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
case 2:
|
||||
{
|
||||
@@ -919,8 +921,7 @@ png_do_unshift(png_row_info *row_info, png_bytef *row,
|
||||
case 4:
|
||||
{
|
||||
png_byte mask;
|
||||
|
||||
mask = (png_byte)(((int)0xf0 >> shift[0]) & (int)0xf0) |
|
||||
mask = (png_byte)(((int)0xf0 >> shift[0]) & (int)0xf0) |
|
||||
((int)0xf >> shift[0]);
|
||||
for (bp = row, i = 0;
|
||||
i < row_info->rowbytes;
|
||||
@@ -938,7 +939,7 @@ png_do_unshift(png_row_info *row_info, png_bytef *row,
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < row_info->channels; c++, bp++)
|
||||
for (c = 0; c < row_info->channels; c++, bp++)
|
||||
{
|
||||
*bp >>= shift[c];
|
||||
}
|
||||
@@ -956,7 +957,7 @@ png_do_unshift(png_row_info *row_info, png_bytef *row,
|
||||
{
|
||||
value = (*bp << 8) + *(bp + 1);
|
||||
value >>= shift[c];
|
||||
*bp = value >> 8;
|
||||
*bp = value >> 8;
|
||||
*(bp + 1) = value & 0xff;
|
||||
}
|
||||
}
|
||||
@@ -970,17 +971,24 @@ png_do_unshift(png_row_info *row_info, png_bytef *row,
|
||||
#if defined(PNG_READ_16_TO_8_SUPPORTED)
|
||||
/* chop rows of bit depth 16 down to 8 */
|
||||
void
|
||||
png_do_chop(png_row_info *row_info, png_bytef *row)
|
||||
png_do_chop(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
if (row && row_info && row_info->bit_depth == 16)
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
if (row && row_info && row_info->bit_depth == 16)
|
||||
{
|
||||
png_bytef *sp = row, *dp = row;
|
||||
png_uint_32 i;
|
||||
|
||||
sp = row;
|
||||
dp = row;
|
||||
for (i = 0; i < row_info->width * row_info->channels; i++)
|
||||
{
|
||||
*dp++ = ((((*sp << 8 | *(sp + 1)) - *sp) + 0x7F) >> 8) & 0xFF;
|
||||
sp += 2;
|
||||
*dp = *sp;
|
||||
/* not yet, as I'm afraid of overflow here
|
||||
*dp = ((((((png_uint_16)(*sp) << 8)) |
|
||||
(png_uint_16)((*(sp + 1) - *sp) & 0xff) +
|
||||
0x7f) >> 8) & 0xff);
|
||||
*/
|
||||
sp += 2;
|
||||
dp++;
|
||||
}
|
||||
row_info->bit_depth = 8;
|
||||
row_info->pixel_depth = 8 * row_info->channels;
|
||||
@@ -992,10 +1000,10 @@ png_do_chop(png_row_info *row_info, png_bytef *row)
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED)
|
||||
/* add filler byte */
|
||||
void
|
||||
png_do_read_filler(png_row_info *row_info, png_bytef *row,
|
||||
png_do_read_filler(png_row_infop row_info, png_bytep row,
|
||||
png_byte filler, png_byte filler_loc)
|
||||
{
|
||||
png_bytef *sp, *dp;
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
if (row && row_info && row_info->color_type == 2 &&
|
||||
row_info->bit_depth == 8)
|
||||
@@ -1040,10 +1048,11 @@ png_do_read_filler(png_row_info *row_info, png_bytef *row,
|
||||
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
|
||||
/* expand grayscale files to rgb, with or without alpha */
|
||||
void
|
||||
png_do_gray_to_rgb(png_row_info *row_info, png_bytef *row)
|
||||
png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
|
||||
{
|
||||
png_bytef *sp, *dp;
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row && row_info && row_info->bit_depth >= 8 &&
|
||||
!(row_info->color_type & PNG_COLOR_MASK_COLOR))
|
||||
{
|
||||
@@ -1130,7 +1139,7 @@ png_do_gray_to_rgb(png_row_info *row_info, png_bytef *row)
|
||||
paletted. Most useful for gamma correction and simplification
|
||||
of code. */
|
||||
void
|
||||
png_build_grayscale_palette(int bit_depth, png_color *palette)
|
||||
png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
||||
{
|
||||
int num_palette;
|
||||
int color_inc;
|
||||
@@ -1160,7 +1169,6 @@ png_build_grayscale_palette(int bit_depth, png_color *palette)
|
||||
break;
|
||||
default:
|
||||
num_palette = 0;
|
||||
color_inc = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1174,7 +1182,7 @@ png_build_grayscale_palette(int bit_depth, png_color *palette)
|
||||
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
void
|
||||
png_correct_palette(png_struct *png_ptr, png_color *palette,
|
||||
png_correct_palette(png_structp png_ptr, png_colorp palette,
|
||||
int num_palette)
|
||||
{
|
||||
if ((png_ptr->transformations & (PNG_GAMMA)) &&
|
||||
@@ -1344,15 +1352,16 @@ png_correct_palette(png_struct *png_ptr, png_color *palette,
|
||||
background is the color (in rgb or grey or palette index, as
|
||||
appropriate). note that paletted files are taken care of elsewhere */
|
||||
void
|
||||
png_do_background(png_row_info *row_info, png_bytef *row,
|
||||
png_color_16 *trans_values, png_color_16 *background,
|
||||
png_color_16 *background_1,
|
||||
png_byte *gamma_table, png_byte *gamma_from_1, png_byte *gamma_to_1,
|
||||
png_uint_16 **gamma_16, png_uint_16 **gamma_16_from_1,
|
||||
png_uint_16 **gamma_16_to_1, int gamma_shift)
|
||||
png_do_background(png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_values, png_color_16p background,
|
||||
png_color_16p background_1,
|
||||
png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
|
||||
png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
|
||||
png_uint_16pp gamma_16_to_1, int gamma_shift)
|
||||
{
|
||||
png_bytef *sp, *dp;
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
int shift;
|
||||
if (row && row_info && background &&
|
||||
(!(row_info->color_type & PNG_COLOR_MASK_ALPHA) ||
|
||||
@@ -2016,15 +2025,16 @@ png_do_background(png_row_info *row_info, png_bytef *row,
|
||||
you do this after you deal with the trasparency issue on grayscale
|
||||
or rgb images. If your bit depth is 8, use gamma_table, if it is 16,
|
||||
use gamma_16_table and gamma_shift. Build these with
|
||||
build_gamma_table(). If your bit depth <= 8, gamma correct a
|
||||
build_gamma_table(). If your bit depth < 8, gamma correct a
|
||||
palette, not the data. */
|
||||
void
|
||||
png_do_gamma(png_row_info *row_info, png_bytef *row,
|
||||
png_byte *gamma_table, png_uint_16 **gamma_16_table,
|
||||
png_do_gamma(png_row_infop row_info, png_bytep row,
|
||||
png_bytep gamma_table, png_uint_16pp gamma_16_table,
|
||||
int gamma_shift)
|
||||
{
|
||||
png_bytef *sp;
|
||||
png_bytep sp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row && row_info && ((row_info->bit_depth <= 8 && gamma_table) ||
|
||||
(row_info->bit_depth == 16 && gamma_16_table)))
|
||||
{
|
||||
@@ -2177,13 +2187,14 @@ png_do_gamma(png_row_info *row_info, png_bytef *row,
|
||||
/* expands a palette row to an rgb or rgba row depending
|
||||
upon whether you supply trans and num_trans */
|
||||
void
|
||||
png_do_expand_palette(png_row_info *row_info, png_bytef *row,
|
||||
png_color *palette,
|
||||
png_byte *trans, int num_trans)
|
||||
png_do_expand_palette(png_row_infop row_info, png_bytep row,
|
||||
png_colorp palette,
|
||||
png_bytep trans, int num_trans)
|
||||
{
|
||||
int shift, value;
|
||||
png_bytef *sp, *dp;
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row && row_info && row_info->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
if (row_info->bit_depth < 8)
|
||||
@@ -2311,14 +2322,15 @@ png_do_expand_palette(png_row_info *row_info, png_bytef *row,
|
||||
}
|
||||
|
||||
/* if the bit depth < 8, it is expanded to 8. Also, if the
|
||||
transparency value is supplied, an alpha channel is built. */
|
||||
transparency value is supplied, an alpha channel is built. */
|
||||
void
|
||||
png_do_expand(png_row_info *row_info, png_bytef *row,
|
||||
png_color_16 *trans_value)
|
||||
png_do_expand(png_row_infop row_info, png_bytep row,
|
||||
png_color_16p trans_value)
|
||||
{
|
||||
int shift, value;
|
||||
png_bytef *sp, *dp;
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row && row_info)
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||
@@ -2411,7 +2423,7 @@ png_do_expand(png_row_info *row_info, png_bytef *row,
|
||||
*dp-- = 0xff;
|
||||
*dp-- = *sp--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (row_info->bit_depth == 16)
|
||||
{
|
||||
sp = row + (png_size_t)row_info->rowbytes - 1;
|
||||
@@ -2429,7 +2441,7 @@ png_do_expand(png_row_info *row_info, png_bytef *row,
|
||||
*dp-- = 0xff;
|
||||
*dp-- = 0xff;
|
||||
}
|
||||
*dp-- = *sp--;
|
||||
*dp-- = *sp--;
|
||||
*dp-- = *sp--;
|
||||
}
|
||||
}
|
||||
@@ -2447,7 +2459,7 @@ png_do_expand(png_row_info *row_info, png_bytef *row,
|
||||
dp = row + (png_size_t)(row_info->width << 2) - 1;
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
if (*(sp - 2) == trans_value->red &&
|
||||
if (*(sp - 2) == trans_value->red &&
|
||||
*(sp - 1) == trans_value->green &&
|
||||
*(sp - 0) == trans_value->blue)
|
||||
*dp-- = 0;
|
||||
@@ -2465,7 +2477,7 @@ png_do_expand(png_row_info *row_info, png_bytef *row,
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
{
|
||||
if ((((png_uint_16)*(sp - 4) |
|
||||
((png_uint_16)*(sp - 5) << 8)) == trans_value->red) &&
|
||||
((png_uint_16)*(sp - 5) << 8)) == trans_value->red) &&
|
||||
(((png_uint_16)*(sp - 2) |
|
||||
((png_uint_16)*(sp - 3) << 8)) == trans_value->green) &&
|
||||
(((png_uint_16)*(sp - 0) |
|
||||
@@ -2483,7 +2495,7 @@ png_do_expand(png_row_info *row_info, png_bytef *row,
|
||||
*dp-- = *sp--;
|
||||
*dp-- = *sp--;
|
||||
*dp-- = *sp--;
|
||||
*dp-- = *sp--;
|
||||
*dp-- = *sp--;
|
||||
*dp-- = *sp--;
|
||||
}
|
||||
}
|
||||
@@ -2499,11 +2511,12 @@ png_do_expand(png_row_info *row_info, png_bytef *row,
|
||||
|
||||
#if defined(PNG_READ_DITHER_SUPPORTED)
|
||||
void
|
||||
png_do_dither(png_row_info *row_info, png_bytef *row,
|
||||
png_byte *palette_lookup, png_byte *dither_lookup)
|
||||
png_do_dither(png_row_infop row_info, png_bytep row,
|
||||
png_bytep palette_lookup, png_bytep dither_lookup)
|
||||
{
|
||||
png_bytef *sp, *dp;
|
||||
png_bytep sp, dp;
|
||||
png_uint_32 i;
|
||||
|
||||
if (row && row_info)
|
||||
{
|
||||
if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
@@ -2529,7 +2542,7 @@ png_do_dither(png_row_info *row_info, png_bytef *row,
|
||||
((1 << PNG_DITHER_RED_BITS) - 1)) <<
|
||||
(PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) |
|
||||
(((g >> (8 - PNG_DITHER_GREEN_BITS)) &
|
||||
((1 << PNG_DITHER_GREEN_BITS) - 1)) <<
|
||||
((1 << PNG_DITHER_GREEN_BITS) - 1)) <<
|
||||
(PNG_DITHER_BLUE_BITS)) |
|
||||
((b >> (8 - PNG_DITHER_BLUE_BITS)) &
|
||||
((1 << PNG_DITHER_BLUE_BITS) - 1));
|
||||
@@ -2556,7 +2569,7 @@ png_do_dither(png_row_info *row_info, png_bytef *row,
|
||||
sp++;
|
||||
|
||||
p = (((r >> (8 - PNG_DITHER_RED_BITS)) &
|
||||
((1 << PNG_DITHER_RED_BITS) - 1)) <<
|
||||
((1 << PNG_DITHER_RED_BITS) - 1)) <<
|
||||
(PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) |
|
||||
(((g >> (8 - PNG_DITHER_GREEN_BITS)) &
|
||||
((1 << PNG_DITHER_GREEN_BITS) - 1)) <<
|
||||
@@ -2574,7 +2587,7 @@ png_do_dither(png_row_info *row_info, png_bytef *row,
|
||||
}
|
||||
else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
dither_lookup && row_info->bit_depth == 8)
|
||||
{
|
||||
{
|
||||
sp = row;
|
||||
for (i = 0; i < row_info->width; i++, sp++)
|
||||
{
|
||||
@@ -2590,7 +2603,7 @@ static int png_gamma_shift[] =
|
||||
{0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0};
|
||||
|
||||
void
|
||||
png_build_gamma_table(png_struct *png_ptr)
|
||||
png_build_gamma_table(png_structp png_ptr)
|
||||
{
|
||||
if (png_ptr->bit_depth <= 8)
|
||||
{
|
||||
@@ -2599,7 +2612,7 @@ png_build_gamma_table(png_struct *png_ptr)
|
||||
|
||||
g = 1.0 / (png_ptr->gamma * png_ptr->display_gamma);
|
||||
|
||||
png_ptr->gamma_table = (png_byte *)png_malloc(png_ptr,
|
||||
png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
@@ -2612,7 +2625,7 @@ png_build_gamma_table(png_struct *png_ptr)
|
||||
{
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
|
||||
png_ptr->gamma_to_1 = (png_byte *)png_malloc(png_ptr,
|
||||
png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
@@ -2623,7 +2636,7 @@ png_build_gamma_table(png_struct *png_ptr)
|
||||
|
||||
g = 1.0 / (png_ptr->display_gamma);
|
||||
|
||||
png_ptr->gamma_from_1 = (png_byte *)png_malloc(png_ptr,
|
||||
png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)256);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
@@ -2633,16 +2646,15 @@ png_build_gamma_table(png_struct *png_ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
double g;
|
||||
int i, j, shift, num;
|
||||
png_uint_32 ig;
|
||||
#if defined(PNG_READ_sBIT_SUPPORTED)
|
||||
int sig_bit;
|
||||
int i, j, shift, num;
|
||||
int sig_bit;
|
||||
png_uint_32 ig;
|
||||
|
||||
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
|
||||
{
|
||||
{
|
||||
sig_bit = (int)png_ptr->sig_bit.red;
|
||||
if ((int)png_ptr->sig_bit.green > sig_bit)
|
||||
sig_bit = png_ptr->sig_bit.green;
|
||||
@@ -2652,13 +2664,12 @@ png_build_gamma_table(png_struct *png_ptr)
|
||||
else
|
||||
{
|
||||
sig_bit = (int)png_ptr->sig_bit.gray;
|
||||
}
|
||||
}
|
||||
|
||||
if (sig_bit > 0)
|
||||
shift = 16 - sig_bit;
|
||||
else
|
||||
#endif /* PNG_READ_sBIT_SUPPORTED */
|
||||
shift = 0;
|
||||
shift = 0;
|
||||
|
||||
if (png_ptr->transformations & PNG_16_TO_8)
|
||||
{
|
||||
@@ -2666,58 +2677,60 @@ png_build_gamma_table(png_struct *png_ptr)
|
||||
shift = (16 - PNG_MAX_GAMMA_8);
|
||||
}
|
||||
|
||||
if (shift > 8)
|
||||
if (shift > 8)
|
||||
shift = 8;
|
||||
if (shift < 0)
|
||||
shift = 0;
|
||||
|
||||
png_ptr->gamma_shift = shift;
|
||||
png_ptr->gamma_shift = shift;
|
||||
|
||||
num = (1 << (8 - shift));
|
||||
num = (1 << (8 - shift));
|
||||
|
||||
g = 1.0 / (png_ptr->gamma * png_ptr->display_gamma);
|
||||
|
||||
png_ptr->gamma_16_table = (png_uint_16 **)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16 *));
|
||||
png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16p ));
|
||||
|
||||
if ((png_ptr->transformations & PNG_16_TO_8) &&
|
||||
!(png_ptr->transformations & PNG_BACKGROUND))
|
||||
{
|
||||
double fin, fout;
|
||||
png_uint_32 last, max;
|
||||
double fin, fout;
|
||||
png_uint_32 last, max;
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16 *)png_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
}
|
||||
|
||||
g = 1.0 / g;
|
||||
last = 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
fout = ((double)i + 0.5) / 256.0;
|
||||
fin = pow(fout, g);
|
||||
max = (png_uint_32)(fin * (double)(num << 8));
|
||||
while (last <= max)
|
||||
{
|
||||
png_ptr->gamma_16_table[(int)(last >> 8)][(int)(last & 0xff)] =
|
||||
(png_uint_16)i | ((png_uint_16)i << 8);
|
||||
g = 1.0 / g;
|
||||
last = 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
fout = ((double)i + 0.5) / 256.0;
|
||||
fin = pow(fout, g);
|
||||
max = (png_uint_32)(fin * (double)(num << 8));
|
||||
while (last <= max)
|
||||
{
|
||||
png_ptr->gamma_16_table[(int)(last & 0xff) >> shift]
|
||||
[(int)(last >> (8 - shift))] =
|
||||
(png_uint_16)i | ((png_uint_16)i << 8);
|
||||
last++;
|
||||
}
|
||||
}
|
||||
while (last < (num << 8))
|
||||
{
|
||||
png_ptr->gamma_16_table[(int)(last >> 8)][(int)(last & 0xff)] =
|
||||
(png_uint_16)65535L;
|
||||
last++;
|
||||
}
|
||||
}
|
||||
while (last < ((png_uint_32)num << 8))
|
||||
{
|
||||
png_ptr->gamma_16_table[(int)(last & 0xff) >> shift]
|
||||
[(int)(last >> (8 - shift))] =
|
||||
(png_uint_16)65535L;
|
||||
last++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16 *)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
@@ -2735,12 +2748,12 @@ png_build_gamma_table(png_struct *png_ptr)
|
||||
{
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
|
||||
png_ptr->gamma_16_to_1 = (png_uint_16 **)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16 *));
|
||||
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16p ));
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_to_1[i] = (png_uint_16 *)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
@@ -2754,12 +2767,12 @@ png_build_gamma_table(png_struct *png_ptr)
|
||||
}
|
||||
g = 1.0 / (png_ptr->display_gamma);
|
||||
|
||||
png_ptr->gamma_16_from_1 = (png_uint_16 **)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16 *));
|
||||
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
|
||||
num * sizeof (png_uint_16p));
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_from_1[i] = (png_uint_16 *)png_malloc(png_ptr,
|
||||
png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
256 * sizeof (png_uint_16));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
|
||||
Reference in New Issue
Block a user