pngrutil.c revision f9a51917495bc8ba8b60632219652a7b122c1190
/* pngrutil.c - utilities to read a PNG file
*
* libpng version 1.2.8 - December 3, 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)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* This file contains routines that are only called from within
* libpng itself during the course of reading an image.
*/
#define PNG_INTERNAL
#include "png.h"
#if defined(_WIN32_WCE)
/* strtod() function is not supported on WindowsCE */
# ifdef PNG_FLOATING_POINT_SUPPORTED
{
double result = 0;
int len;
{
}
return result;
}
# endif
#endif
png_uint_32 /* PRIVATE */
{
if (i > PNG_UINT_31_MAX)
return (i);
}
#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
png_uint_32 /* PRIVATE */
{
return (i);
}
#if defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_oFFs_SUPPORTED)
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
* data is stored in the PNG file in two's complement format, and it is
* assumed that the machine format for signed integers is the same. */
png_int_32 /* PRIVATE */
{
return (i);
}
#endif /* PNG_READ_pCAL_SUPPORTED */
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
png_uint_16 /* PRIVATE */
{
return (i);
}
#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */
/* Read data, and (optionally) run it through the CRC. */
void /* PRIVATE */
{
}
/* Optionally skip data and then check the CRC. Depending on whether we
are reading a ancillary or critical chunk, and how the program has set
things up, we may calculate the CRC on the data and print a message.
Returns '1' if there was a CRC error, '0' otherwise. */
int /* PRIVATE */
{
png_size_t i;
{
}
if (i)
{
}
if (png_crc_error(png_ptr))
{
{
}
else
{
}
return (1);
}
return (0);
}
/* Compare the CRC stored in the PNG file with that calculated by libpng from
the data it has read thus far. */
int /* PRIVATE */
{
int need_crc = 1;
{
need_crc = 0;
}
else /* critical */
{
need_crc = 0;
}
if (need_crc)
{
}
else
return (0);
}
#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \
defined(PNG_READ_iCCP_SUPPORTED)
/*
* Decompress trailing data in a chunk. The assumption is that chunkdata
* points at an allocated area holding the contents of a chunk with a
* trailing compressed part. What we get back is an allocated area
* holding the original prefix part and an uncompressed version of the
* trailing part (the malloc area passed in is freed).
*/
png_charp /* PRIVATE */
{
static char msg[] = "Error decoding compressed text";
if (comp_type == PNG_COMPRESSION_TYPE_BASE)
{
text_size = 0;
{
{
else
{
{
}
}
/* Copy what we can of the error message into the text chunk */
break;
}
{
{
text_size = prefix_size +
{
}
text_size - prefix_size);
}
else
{
(png_uint_32)(text_size +
{
}
}
if (ret == Z_STREAM_END)
break;
else
{
}
}
}
if (ret != Z_STREAM_END)
{
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char umsg[50];
if (ret == Z_BUF_ERROR)
else if (ret == Z_DATA_ERROR)
else
#else
"Incomplete compressed datastream in chunk other than IDAT");
#endif
{
{
}
}
}
}
else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */
{
#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
char umsg[50];
#else
#endif
}
return chunkdata;
}
#endif
/* read and check the IDHR chunk */
void /* PRIVATE */
{
int interlace_type;
/* check the length */
if (length != 13)
png_crc_finish(png_ptr, 0);
/* set internal variables */
#if defined(PNG_MNG_FEATURES_SUPPORTED)
#endif
/* find number of channels */
switch (png_ptr->color_type)
{
case PNG_COLOR_TYPE_GRAY:
case PNG_COLOR_TYPE_PALETTE:
break;
case PNG_COLOR_TYPE_RGB:
break;
break;
case PNG_COLOR_TYPE_RGB_ALPHA:
break;
}
/* set up other useful info */
}
/* read and check the palette */
void /* PRIVATE */
{
int num, i;
#ifndef PNG_NO_POINTER_INDEXING
#endif
{
return;
}
{
"Ignoring PLTE chunk in grayscale PNG");
return;
}
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
{
return;
}
#endif
{
{
return;
}
else
{
}
}
#ifndef PNG_NO_POINTER_INDEXING
{
}
#else
for (i = 0; i < num; i++)
{
/* don't depend upon png_color being any order */
}
#endif
/* If we actually NEED the PLTE chunk (ie for a paletted image), we do
whatever the normal CRC configuration tells us. However, if we
have an RGB image, the PLTE can be considered ancillary, so
we will act as though it is. */
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
#endif
{
png_crc_finish(png_ptr, 0);
}
#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
{
/* If we don't want to use the data from an ancillary chunk,
we have two options: an error abort, or a warning and we
ignore the data in this chunk (which should be OK, since
it's considered ancillary for a RGB or RGBA image). */
{
{
}
else
{
return;
}
}
/* Otherwise, we (optionally) emit a warning and use the chunk. */
{
}
}
#endif
#if defined(PNG_READ_tRNS_SUPPORTED)
{
{
{
}
{
}
}
}
#endif
}
void /* PRIVATE */
{
{
}
if (length != 0)
{
}
return;
}
#if defined(PNG_READ_gAMA_SUPPORTED)
void /* PRIVATE */
{
#ifdef PNG_FLOATING_POINT_SUPPORTED
float file_gamma;
#endif
{
return;
}
/* Should be an error, but we can cope with it */
#if defined(PNG_READ_sRGB_SUPPORTED)
#endif
)
{
return;
}
if (length != 4)
{
return;
}
if (png_crc_finish(png_ptr, 0))
return;
/* check for zero gamma */
if (igamma == 0)
{
"Ignoring gAMA chunk with gamma=0");
return;
}
#if defined(PNG_READ_sRGB_SUPPORTED)
{
"Ignoring incorrect gAMA value when sRGB is also present");
#ifndef PNG_NO_CONSOLE_IO
#endif
return;
}
#endif /* PNG_READ_sRGB_SUPPORTED */
#ifdef PNG_FLOATING_POINT_SUPPORTED
# ifdef PNG_READ_GAMMA_SUPPORTED
# endif
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
#endif
}
#endif
#if defined(PNG_READ_sBIT_SUPPORTED)
void /* PRIVATE */
{
{
return;
}
{
/* Should be an error, but we can cope with it */
}
{
return;
}
truelen = 3;
else
{
return;
}
if (png_crc_finish(png_ptr, 0))
return;
{
}
else
{
}
}
#endif
#if defined(PNG_READ_cHRM_SUPPORTED)
void /* PRIVATE */
{
#ifdef PNG_FLOATING_POINT_SUPPORTED
#endif
{
return;
}
/* Should be an error, but we can cope with it */
#if defined(PNG_READ_sRGB_SUPPORTED)
#endif
)
{
return;
}
if (length != 32)
{
return;
}
{
return;
}
{
return;
}
{
return;
}
{
png_crc_finish(png_ptr, 0);
return;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED
#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
{
{
"Ignoring incorrect cHRM value when sRGB is also present");
#ifndef PNG_NO_CONSOLE_IO
#ifdef PNG_FLOATING_POINT_SUPPORTED
#else
#endif
#endif /* PNG_NO_CONSOLE_IO */
}
png_crc_finish(png_ptr, 0);
return;
}
#endif /* PNG_READ_sRGB_SUPPORTED */
#ifdef PNG_FLOATING_POINT_SUPPORTED
#endif
#ifdef PNG_FIXED_POINT_SUPPORTED
#endif
if (png_crc_finish(png_ptr, 0))
return;
}
#endif
#if defined(PNG_READ_sRGB_SUPPORTED)
void /* PRIVATE */
{
int intent;
{
return;
}
/* Should be an error, but we can cope with it */
{
return;
}
if (length != 1)
{
return;
}
if (png_crc_finish(png_ptr, 0))
return;
/* check for bad intent */
if (intent >= PNG_sRGB_INTENT_LAST)
{
return;
}
#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
{
#ifdef PNG_FIXED_POINT_SUPPORTED
#else
# ifdef PNG_FLOATING_POINT_SUPPORTED
# endif
#endif
{
"Ignoring incorrect gAMA value when sRGB is also present");
#ifndef PNG_NO_CONSOLE_IO
# ifdef PNG_FIXED_POINT_SUPPORTED
# else
# ifdef PNG_FLOATING_POINT_SUPPORTED
# endif
# endif
#endif
}
}
#endif /* PNG_READ_gAMA_SUPPORTED */
#ifdef PNG_READ_cHRM_SUPPORTED
#ifdef PNG_FIXED_POINT_SUPPORTED
{
"Ignoring incorrect cHRM value when sRGB is also present");
}
#endif /* PNG_FIXED_POINT_SUPPORTED */
#endif /* PNG_READ_cHRM_SUPPORTED */
}
#endif /* PNG_READ_sRGB_SUPPORTED */
#if defined(PNG_READ_iCCP_SUPPORTED)
void /* PRIVATE */
/* Note: this does not properly handle chunks that are > 64K under DOS */
{
png_uint_32 skip = 0;
{
return;
}
/* Should be an error, but we can cope with it */
{
return;
}
#ifdef PNG_MAX_MALLOC_64K
{
}
#endif
{
return;
}
/* empty loop to find end of name */ ;
++profile;
/* there should be at least one zero (the compression type byte)
following the separator, and we should be on it */
{
return;
}
/* compression_type should always be zero */
compression_type = *profile++;
if (compression_type)
{
wrote nonzero) */
}
{
return;
}
/* Check the profile_size recorded in the first 32 bits of the ICC profile */
((*(pC+3)) );
if(profile_size < profile_length)
if(profile_size > profile_length)
{
return;
}
}
#endif /* PNG_READ_iCCP_SUPPORTED */
#if defined(PNG_READ_sPLT_SUPPORTED)
void /* PRIVATE */
/* Note: this does not properly handle chunks that are > 64K under DOS */
{
#ifdef PNG_NO_POINTER_INDEXING
#endif
int data_length, entry_size, i;
png_uint_32 skip = 0;
{
return;
}
#ifdef PNG_MAX_MALLOC_64K
{
}
#endif
{
return;
}
/* empty loop to find end of name */ ;
++entry_start;
/* a sample depth should follow the separator, and we should be on it */
{
return;
}
/* integrity-check the data length */
if (data_length % entry_size)
{
return;
}
{
return;
}
{
return;
}
#ifndef PNG_NO_POINTER_INDEXING
for (i = 0; i < new_palette.nentries; i++)
{
{
}
else
{
}
}
#else
for (i = 0; i < new_palette.nentries; i++)
{
{
}
else
{
}
}
#endif
/* discard all chunk data except the name and stash that */
}
#endif /* PNG_READ_sPLT_SUPPORTED */
#if defined(PNG_READ_tRNS_SUPPORTED)
void /* PRIVATE */
{
{
return;
}
{
return;
}
{
if (length != 2)
{
return;
}
}
{
if (length != 6)
{
return;
}
}
{
{
/* Should be an error, but we can cope with it. */
}
{
return;
}
if (length == 0)
{
return;
}
}
else
{
return;
}
if (png_crc_finish(png_ptr, 0))
return;
&(png_ptr->trans_values));
}
#endif
#if defined(PNG_READ_bKGD_SUPPORTED)
void /* PRIVATE */
{
{
return;
}
{
return;
}
{
return;
}
truelen = 1;
truelen = 6;
else
truelen = 2;
{
return;
}
if (png_crc_finish(png_ptr, 0))
return;
/* We convert the index value into RGB components so that we can allow
* arbitrary RGB values for background when we have transparency, and
* so it is easy to determine the RGB values of the background color
* from the info_ptr struct. */
{
if(info_ptr->num_palette)
{
{
return;
}
}
}
{
}
else
{
}
}
#endif
#if defined(PNG_READ_hIST_SUPPORTED)
void /* PRIVATE */
{
unsigned int num, i;
{
return;
}
{
return;
}
{
return;
}
(unsigned int) PNG_MAX_PALETTE_LENGTH)
{
return;
}
for (i = 0; i < num; i++)
{
}
if (png_crc_finish(png_ptr, 0))
return;
}
#endif
#if defined(PNG_READ_pHYs_SUPPORTED)
void /* PRIVATE */
{
int unit_type;
{
return;
}
{
return;
}
if (length != 9)
{
return;
}
if (png_crc_finish(png_ptr, 0))
return;
}
#endif
#if defined(PNG_READ_oFFs_SUPPORTED)
void /* PRIVATE */
{
int unit_type;
{
return;
}
{
return;
}
if (length != 9)
{
return;
}
if (png_crc_finish(png_ptr, 0))
return;
}
#endif
#if defined(PNG_READ_pCAL_SUPPORTED)
/* read the pCAL chunk (described in the PNG Extensions document) */
void /* PRIVATE */
{
int i;
{
return;
}
{
return;
}
length + 1);
{
return;
}
if (png_crc_finish(png_ptr, 0))
{
return;
}
/* empty loop */ ;
/* We need to have at least 12 bytes after the purpose string
in order to get the parameter information. */
{
return;
}
/* Check that we have the right number of parameters for known
equation types. */
{
return;
}
else if (type >= PNG_EQUATION_LAST)
{
}
/* Empty loop to move past the units string. */ ;
*png_sizeof(png_charp))) ;
{
return;
}
/* Get pointers to the start of each parameter string. */
for (i = 0; i < (int)nparams; i++)
{
buf++; /* Skip the null string terminator from previous parameter. */
/* Empty loop to move past each parameter string */ ;
/* Make sure we haven't run out of data yet */
{
return;
}
}
}
#endif
#if defined(PNG_READ_sCAL_SUPPORTED)
/* read the sCAL chunk */
void /* PRIVATE */
{
#ifdef PNG_FLOATING_POINT_SUPPORTED
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
#endif
#endif
{
return;
}
{
return;
}
length + 1);
{
return;
}
if (png_crc_finish(png_ptr, 0))
{
return;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED
if (*vp)
{
return;
}
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
{
return;
}
#endif
#endif
/* empty loop */ ;
ep++;
#ifdef PNG_FLOATING_POINT_SUPPORTED
if (*vp)
{
return;
}
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
{
return;
}
#endif
#endif
#ifdef PNG_FLOATING_POINT_SUPPORTED
#endif
)
{
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
#endif
return;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
#endif
#endif
#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
#endif
}
#endif
#if defined(PNG_READ_tIME_SUPPORTED)
void /* PRIVATE */
{
{
return;
}
if (length != 7)
{
return;
}
if (png_crc_finish(png_ptr, 0))
return;
}
#endif
#if defined(PNG_READ_tEXt_SUPPORTED)
/* Note: this does not properly handle chunks that are > 64K under DOS */
void /* PRIVATE */
{
png_uint_32 skip = 0;
int ret;
#ifdef PNG_MAX_MALLOC_64K
{
}
#endif
{
return;
}
{
return;
}
/* empty loop to find end of key */ ;
text++;
{
return;
}
#ifdef PNG_iTXt_SUPPORTED
text_ptr->itxt_length = 0;
#endif
if (ret)
}
#endif
#if defined(PNG_READ_zTXt_SUPPORTED)
/* note: this does not correctly handle chunks that are > 64K under DOS */
void /* PRIVATE */
{
int comp_type;
int ret;
#ifdef PNG_MAX_MALLOC_64K
/* We will no doubt have problems with chunks even half this size, but
there is no hard and fast rule to tell us where to stop. */
{
return;
}
#endif
{
return;
}
if (png_crc_finish(png_ptr, 0))
{
return;
}
/* empty loop */ ;
/* zTXt must have some text after the chunkdataword */
{
}
else
{
if (comp_type != PNG_TEXT_COMPRESSION_zTXt)
{
}
text++; /* skip the compression_method byte */
}
{
return;
}
#ifdef PNG_iTXt_SUPPORTED
text_ptr->itxt_length = 0;
#endif
if (ret)
}
#endif
#if defined(PNG_READ_iTXt_SUPPORTED)
/* note: this does not correctly handle chunks that are > 64K under DOS */
void /* PRIVATE */
{
int comp_flag;
int comp_type = 0;
int ret;
#ifdef PNG_MAX_MALLOC_64K
/* We will no doubt have problems with chunks even half this size, but
there is no hard and fast rule to tell us where to stop. */
{
return;
}
#endif
{
return;
}
if (png_crc_finish(png_ptr, 0))
{
return;
}
/* empty loop */ ;
lang++; /* skip NUL separator */
/* iTXt must have a language tag (possibly empty), two compression bytes,
translated keyword (possibly empty), and possibly some text after the
keyword */
{
}
else
{
}
/* empty loop */ ;
lang_key++; /* skip NUL separator */
/* empty loop */ ;
text++; /* skip NUL separator */
if (comp_flag)
else
{
return;
}
text_ptr->text_length = 0;
if (ret)
}
#endif
/* This function is called when we haven't found a handler for a
chunk. If there isn't a problem with the chunk itself (ie bad
chunk name, CRC, or a critical chunk), the chunk is silently ignored
-- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which
case it will be saved away to be written out later. */
void /* PRIVATE */
{
png_uint_32 skip = 0;
{
#ifdef PNG_USE_LOCAL_ARRAYS
#endif
}
{
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
#endif
)
#endif
}
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
{
#ifdef PNG_MAX_MALLOC_64K
{
}
#endif
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
{
/* callback to user unknown chunk handler */
{
{
}
}
}
else
#endif
}
else
#endif
#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
return;
#endif
}
/* This function is called to verify that a chunk name is valid.
This function can't have the "critical chunk check" incorporated
into it, since in the future we will need to be able to call user
functions to handle unknown critical chunks after we check that
the chunk name itself is valid. */
void /* PRIVATE */
{
{
}
}
/* Combines the row recently read in with the existing pixels in the
row. This routine takes care of alpha and transparency if requested.
This routine also handles the two methods of progressive display
of interlaced images, depending on the mask value.
The mask value describes which pixels are to be combined with
the row. The pattern always repeats every 8 pixels, so just 8
bits are needed. A one indicates the pixel is to be combined,
a zero indicates the pixel is to be skipped. This is in addition
to any alpha or transparency value associated with the pixel. If
you want all pixels to be combined, pass 0xff (255) in mask. */
#ifndef PNG_HAVE_ASSEMBLER_COMBINE_ROW
void /* PRIVATE */
{
if (mask == 0xff)
{
}
else
{
{
case 1:
{
int m = 0x80;
int shift;
png_uint_32 i;
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
{
s_start = 0;
s_end = 7;
s_inc = 1;
}
else
#endif
{
s_start = 7;
s_end = 0;
s_inc = -1;
}
for (i = 0; i < row_width; i++)
{
if (m & mask)
{
int value;
}
{
sp++;
dp++;
}
else
if (m == 1)
m = 0x80;
else
m >>= 1;
}
break;
}
case 2:
{
int m = 0x80;
int shift;
png_uint_32 i;
int value;
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
{
s_start = 0;
s_end = 6;
s_inc = 2;
}
else
#endif
{
s_start = 6;
s_end = 0;
s_inc = -2;
}
for (i = 0; i < row_width; i++)
{
if (m & mask)
{
}
{
sp++;
dp++;
}
else
if (m == 1)
m = 0x80;
else
m >>= 1;
}
break;
}
case 4:
{
int m = 0x80;
int shift;
png_uint_32 i;
int value;
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
{
s_start = 0;
s_end = 4;
s_inc = 4;
}
else
#endif
{
s_start = 4;
s_end = 0;
s_inc = -4;
}
for (i = 0; i < row_width; i++)
{
if (m & mask)
{
}
{
sp++;
dp++;
}
else
if (m == 1)
m = 0x80;
else
m >>= 1;
}
break;
}
default:
{
png_uint_32 i;
png_byte m = 0x80;
for (i = 0; i < row_width; i++)
{
if (m & mask)
{
}
sp += pixel_bytes;
dp += pixel_bytes;
if (m == 1)
m = 0x80;
else
m >>= 1;
}
break;
}
}
}
}
#endif /* !PNG_HAVE_ASSEMBLER_COMBINE_ROW */
#ifndef PNG_HAVE_ASSEMBLER_READ_INTERLACE /* else in pngvcrd.c, pnggccrd.c */
/* OLD pre-1.0.9 interface:
void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
png_uint_32 transformations)
*/
void /* PRIVATE */
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* offset to next interlace block */
#endif
{
switch (row_info->pixel_depth)
{
case 1:
{
png_byte v;
png_uint_32 i;
int j;
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (transformations & PNG_PACKSWAP)
{
s_start = 7;
s_end = 0;
s_inc = -1;
}
else
#endif
{
s_start = 0;
s_end = 7;
s_inc = 1;
}
{
for (j = 0; j < jstop; j++)
{
{
dp--;
}
else
}
{
sp--;
}
else
}
break;
}
case 2:
{
png_uint_32 i;
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (transformations & PNG_PACKSWAP)
{
s_start = 6;
s_end = 0;
s_inc = -2;
}
else
#endif
{
s_start = 0;
s_end = 6;
s_inc = 2;
}
{
png_byte v;
int j;
for (j = 0; j < jstop; j++)
{
{
dp--;
}
else
}
{
sp--;
}
else
}
break;
}
case 4:
{
png_uint_32 i;
#if defined(PNG_READ_PACKSWAP_SUPPORTED)
if (transformations & PNG_PACKSWAP)
{
s_start = 4;
s_end = 0;
s_inc = -4;
}
else
#endif
{
s_start = 0;
s_end = 4;
s_inc = 4;
}
{
int j;
for (j = 0; j < jstop; j++)
{
{
dp--;
}
else
}
{
sp--;
}
else
}
break;
}
default:
{
png_uint_32 i;
{
png_byte v[8];
int j;
for (j = 0; j < jstop; j++)
{
dp -= pixel_bytes;
}
sp -= pixel_bytes;
}
break;
}
}
}
#if !defined(PNG_READ_PACKSWAP_SUPPORTED)
return;
#endif
}
#endif /* !PNG_HAVE_ASSEMBLER_READ_INTERLACE */
#endif /* PNG_READ_INTERLACING_SUPPORTED */
void /* PRIVATE */
{
switch (filter)
{
case PNG_FILTER_VALUE_NONE:
break;
case PNG_FILTER_VALUE_SUB:
{
png_uint_32 i;
{
rp++;
}
break;
}
case PNG_FILTER_VALUE_UP:
{
png_uint_32 i;
for (i = 0; i < istop; i++)
{
rp++;
}
break;
}
case PNG_FILTER_VALUE_AVG:
{
png_uint_32 i;
for (i = 0; i < bpp; i++)
{
rp++;
}
for (i = 0; i < istop; i++)
{
rp++;
}
break;
}
case PNG_FILTER_VALUE_PAETH:
{
png_uint_32 i;
for (i = 0; i < bpp; i++)
{
rp++;
}
for (i = 0; i < istop; i++) /* use leftover rp,pp */
{
a = *lp++;
b = *pp++;
c = *cp++;
p = b - c;
pc = a - c;
#ifdef PNG_USE_ABS
#else
pa = p < 0 ? -p : p;
#endif
/*
if (pa <= pb && pa <= pc)
p = a;
else if (pb <= pc)
p = b;
else
p = c;
*/
rp++;
}
break;
}
default:
*row=0;
break;
}
}
#endif /* !PNG_HAVE_ASSEMBLER_READ_FILTER_ROW */
void /* PRIVATE */
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */
/* offset to next interlace block */
/* start of interlace block in the y direction */
/* offset to next interlace block in the y direction */
#endif
png_ptr->row_number++;
return;
if (png_ptr->interlaced)
{
png_ptr->row_number = 0;
do
{
break;
{
continue;
}
else /* if (png_ptr->transformations & PNG_INTERLACE) */
break;
return;
}
{
#ifdef PNG_USE_LOCAL_ARRAYS
#endif
char extra;
int ret;
for(;;)
{
{
{
png_crc_finish(png_ptr, 0);
}
}
if (ret == Z_STREAM_END)
{
break;
}
"Decompression Error");
{
break;
}
}
}
}
void /* PRIVATE */
{
#ifdef PNG_USE_LOCAL_ARRAYS
/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* start of interlace block */
/* offset to next interlace block */
/* start of interlace block in the y direction */
/* offset to next interlace block in the y direction */
#endif
int max_pixel_depth;
if (png_ptr->interlaced)
{
png_pass_ystart[0]) / png_pass_yinc[0];
else
}
else
{
}
#if defined(PNG_READ_PACK_SUPPORTED)
max_pixel_depth = 8;
#endif
#if defined(PNG_READ_EXPAND_SUPPORTED)
{
{
max_pixel_depth = 32;
else
max_pixel_depth = 24;
}
{
if (max_pixel_depth < 8)
max_pixel_depth = 8;
max_pixel_depth *= 2;
}
{
{
max_pixel_depth *= 4;
max_pixel_depth /= 3;
}
}
}
#endif
#if defined(PNG_READ_FILLER_SUPPORTED)
{
max_pixel_depth = 32;
{
if (max_pixel_depth <= 8)
max_pixel_depth = 16;
else
max_pixel_depth = 32;
}
{
if (max_pixel_depth <= 32)
max_pixel_depth = 32;
else
max_pixel_depth = 64;
}
}
#endif
#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
{
if (
#if defined(PNG_READ_EXPAND_SUPPORTED)
#endif
#if defined(PNG_READ_FILLER_SUPPORTED)
#endif
{
if (max_pixel_depth <= 16)
max_pixel_depth = 32;
else
max_pixel_depth = 64;
}
else
{
if (max_pixel_depth <= 8)
{
max_pixel_depth = 32;
else
max_pixel_depth = 24;
}
max_pixel_depth = 64;
else
max_pixel_depth = 48;
}
}
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \
defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
{
}
#endif
/* align the width on the next larger 8 pixels. Mainly used
for interlacing */
/* calculate the maximum bytes needed, adding a byte and a pixel
for safety's sake */
#ifdef PNG_MAX_MALLOC_64K
#endif
#if defined(PNG_DEBUG) && defined(PNG_USE_PNGGCCRD)
#endif
#ifdef PNG_MAX_MALLOC_64K
#endif
}