mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng15] Added palette-index checking.
This commit is contained in:
16
pngwrite.c
16
pngwrite.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.5.7 [December 15, 2011]
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.5.10 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 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.)
|
||||
*
|
||||
@@ -305,6 +305,11 @@ png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
png_error(png_ptr, "No IDATs written into file");
|
||||
|
||||
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
if (png_ptr->num_palette_max > png_ptr->num_palette)
|
||||
png_warning(png_ptr, "Wrote palette index exceeding num_palette");
|
||||
#endif
|
||||
|
||||
/* See if user wants us to write information chunks */
|
||||
if (info_ptr != NULL)
|
||||
{
|
||||
@@ -798,6 +803,13 @@ png_write_row(png_structp png_ptr, png_const_bytep row)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Added at libpng-1.5.10 */
|
||||
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Check for out-of-range palette index */
|
||||
if(row_info.color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
png_do_check_palette_indexes(png_ptr, &row_info);
|
||||
#endif
|
||||
|
||||
/* Find a filter if necessary, filter the row and write it out. */
|
||||
png_write_find_filter(png_ptr, &row_info);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user