mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from libpng-1.2.6beta4.tar
This commit is contained in:
42
pngrtran.c
42
pngrtran.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* libpng version 1.2.6beta3 - July 18, 2004
|
||||
* libpng version 1.2.6beta4 - July 28, 2004
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2004 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -85,7 +85,8 @@ png_set_background(png_structp png_ptr,
|
||||
}
|
||||
|
||||
png_ptr->transformations |= PNG_BACKGROUND;
|
||||
png_memcpy(&(png_ptr->background), background_color, sizeof(png_color_16));
|
||||
png_memcpy(&(png_ptr->background), background_color,
|
||||
png_sizeof(png_color_16));
|
||||
png_ptr->background_gamma = (float)background_gamma;
|
||||
png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
|
||||
png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
|
||||
@@ -154,7 +155,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
int i;
|
||||
|
||||
png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * sizeof (png_byte)));
|
||||
(png_uint_32)(num_palette * png_sizeof (png_byte)));
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->dither_index[i] = (png_byte)i;
|
||||
}
|
||||
@@ -170,7 +171,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
|
||||
/* initialize an array to sort colors */
|
||||
png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * sizeof (png_byte)));
|
||||
(png_uint_32)(num_palette * png_sizeof (png_byte)));
|
||||
|
||||
/* initialize the dither_sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@@ -299,9 +300,9 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
|
||||
/* initialize palette index arrays */
|
||||
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * sizeof (png_byte)));
|
||||
(png_uint_32)(num_palette * png_sizeof (png_byte)));
|
||||
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * sizeof (png_byte)));
|
||||
(png_uint_32)(num_palette * png_sizeof (png_byte)));
|
||||
|
||||
/* initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@@ -311,10 +312,10 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
}
|
||||
|
||||
hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
|
||||
sizeof (png_dsortp)));
|
||||
png_sizeof (png_dsortp)));
|
||||
for (i = 0; i < 769; i++)
|
||||
hash[i] = NULL;
|
||||
/* png_memset(hash, 0, 769 * sizeof (png_dsortp)); */
|
||||
/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */
|
||||
|
||||
num_new_palette = num_palette;
|
||||
|
||||
@@ -344,7 +345,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
{
|
||||
|
||||
t = (png_dsortp)png_malloc_warn(png_ptr,
|
||||
(png_uint_32)(sizeof(png_dsort)));
|
||||
(png_uint_32)(png_sizeof(png_dsort)));
|
||||
if (t == NULL)
|
||||
break;
|
||||
t->next = hash[d];
|
||||
@@ -462,14 +463,15 @@ png_set_dither(png_structp png_ptr, png_colorp palette,
|
||||
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
||||
|
||||
png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
|
||||
(png_uint_32)(num_entries * sizeof (png_byte)));
|
||||
(png_uint_32)(num_entries * png_sizeof (png_byte)));
|
||||
|
||||
png_memset(png_ptr->palette_lookup, 0, num_entries * sizeof (png_byte));
|
||||
png_memset(png_ptr->palette_lookup, 0, num_entries *
|
||||
png_sizeof (png_byte));
|
||||
|
||||
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
||||
sizeof(png_byte)));
|
||||
png_sizeof(png_byte)));
|
||||
|
||||
png_memset(distance, 0xff, num_entries * sizeof(png_byte));
|
||||
png_memset(distance, 0xff, num_entries * png_sizeof(png_byte));
|
||||
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
@@ -4005,7 +4007,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
g = 1.0;
|
||||
|
||||
png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
|
||||
(png_uint_32)(num * sizeof (png_uint_16p)));
|
||||
(png_uint_32)(num * png_sizeof (png_uint_16p)));
|
||||
|
||||
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
|
||||
{
|
||||
@@ -4015,7 +4017,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(256 * sizeof (png_uint_16)));
|
||||
(png_uint_32)(256 * png_sizeof (png_uint_16)));
|
||||
}
|
||||
|
||||
g = 1.0 / g;
|
||||
@@ -4045,7 +4047,7 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(256 * sizeof (png_uint_16)));
|
||||
(png_uint_32)(256 * png_sizeof (png_uint_16)));
|
||||
|
||||
ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4);
|
||||
for (j = 0; j < 256; j++)
|
||||
@@ -4065,12 +4067,12 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
g = 1.0 / (png_ptr->gamma);
|
||||
|
||||
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
|
||||
(png_uint_32)(num * sizeof (png_uint_16p )));
|
||||
(png_uint_32)(num * png_sizeof (png_uint_16p )));
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(256 * sizeof (png_uint_16)));
|
||||
(png_uint_32)(256 * png_sizeof (png_uint_16)));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
(png_uint_32)png_gamma_shift[shift]) >> 4);
|
||||
@@ -4088,12 +4090,12 @@ png_build_gamma_table(png_structp png_ptr)
|
||||
g = png_ptr->gamma; /* probably doing rgb_to_gray */
|
||||
|
||||
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
|
||||
(png_uint_32)(num * sizeof (png_uint_16p)));
|
||||
(png_uint_32)(num * png_sizeof (png_uint_16p)));
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
|
||||
(png_uint_32)(256 * sizeof (png_uint_16)));
|
||||
(png_uint_32)(256 * png_sizeof (png_uint_16)));
|
||||
|
||||
ig = (((png_uint_32)i *
|
||||
(png_uint_32)png_gamma_shift[shift]) >> 4);
|
||||
|
||||
Reference in New Issue
Block a user