mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Imported from libpng-1.0.9beta2.tar
This commit is contained in:
48
pngwutil.c
48
pngwutil.c
@@ -1,9 +1,9 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* libpng 1.0.9beta10 - January 16, 2001
|
||||
* libpng 1.0.9beta2 - November 19, 2000
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2001 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998, 1999, 2000 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.)
|
||||
*/
|
||||
@@ -131,8 +131,6 @@ png_write_sig(png_structp png_ptr)
|
||||
/* write the rest of the 8 byte signature */
|
||||
png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes],
|
||||
(png_size_t)8 - png_ptr->sig_bytes);
|
||||
if(png_ptr->sig_bytes < 3)
|
||||
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED)
|
||||
@@ -421,24 +419,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
compression_type = PNG_COMPRESSION_TYPE_BASE;
|
||||
}
|
||||
|
||||
/* Write filter_method 64 (intrapixel differencing) only if
|
||||
* 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
|
||||
* 2. Libpng did not write a PNG signature (this filter_method is only
|
||||
* used in PNG datastreams that are embedded in MNG datastreams) and
|
||||
* 3. The application called png_permit_mng_features with a mask that
|
||||
* included PNG_FLAG_MNG_FILTER_64 and
|
||||
* 4. The filter_method is 64 and
|
||||
* 5. The color_type is RGB or RGBA
|
||||
*/
|
||||
if (
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
|
||||
(color_type == PNG_COLOR_TYPE_RGB ||
|
||||
color_type == PNG_COLOR_TYPE_RGB_ALPHA) &&
|
||||
(filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&
|
||||
#endif
|
||||
filter_type != PNG_FILTER_TYPE_BASE)
|
||||
if (filter_type != PNG_FILTER_TYPE_BASE)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid filter type specified");
|
||||
filter_type = PNG_FILTER_TYPE_BASE;
|
||||
@@ -459,7 +440,6 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height,
|
||||
png_ptr->bit_depth = (png_byte)bit_depth;
|
||||
png_ptr->color_type = (png_byte)color_type;
|
||||
png_ptr->interlaced = (png_byte)interlace_type;
|
||||
png_ptr->filter_type = (png_byte)filter_type;
|
||||
png_ptr->width = width;
|
||||
png_ptr->height = height;
|
||||
|
||||
@@ -677,7 +657,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
return;
|
||||
}
|
||||
|
||||
if (compression_type != PNG_COMPRESSION_TYPE_BASE)
|
||||
if (compression_type)
|
||||
png_warning(png_ptr, "Unknown compression type in iCCP chunk");
|
||||
|
||||
if (profile == NULL)
|
||||
@@ -685,7 +665,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type,
|
||||
|
||||
if (profile_len)
|
||||
profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len,
|
||||
PNG_COMPRESSION_TYPE_BASE, &comp);
|
||||
PNG_TEXT_COMPRESSION_zTXt, &comp);
|
||||
|
||||
/* make sure we include the NULL after the name and the compression type */
|
||||
png_write_chunk_start(png_ptr, (png_bytep)png_iCCP,
|
||||
@@ -1092,14 +1072,13 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
png_size_t key_len;
|
||||
png_charp kp, dp;
|
||||
int kflag;
|
||||
int kwarn=0;
|
||||
|
||||
png_debug(1, "in png_check_keyword\n");
|
||||
*new_key = NULL;
|
||||
|
||||
if (key == NULL || (key_len = png_strlen(key)) == 0)
|
||||
{
|
||||
png_warning(png_ptr, "zero length keyword");
|
||||
png_chunk_warning(png_ptr, "zero length keyword");
|
||||
return ((png_size_t)0);
|
||||
}
|
||||
|
||||
@@ -1116,9 +1095,9 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
char msg[40];
|
||||
|
||||
sprintf(msg, "invalid keyword character 0x%02X", *kp);
|
||||
png_warning(png_ptr, msg);
|
||||
png_chunk_warning(png_ptr, msg);
|
||||
#else
|
||||
png_warning(png_ptr, "invalid character in keyword");
|
||||
png_chunk_warning(png_ptr, "invalid character in keyword");
|
||||
#endif
|
||||
*dp = ' ';
|
||||
}
|
||||
@@ -1133,7 +1112,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
kp = *new_key + key_len - 1;
|
||||
if (*kp == ' ')
|
||||
{
|
||||
png_warning(png_ptr, "trailing spaces removed from keyword");
|
||||
png_chunk_warning(png_ptr, "trailing spaces removed from keyword");
|
||||
|
||||
while (*kp == ' ')
|
||||
{
|
||||
@@ -1146,7 +1125,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
kp = *new_key;
|
||||
if (*kp == ' ')
|
||||
{
|
||||
png_warning(png_ptr, "leading spaces removed from keyword");
|
||||
png_chunk_warning(png_ptr, "leading spaces removed from keyword");
|
||||
|
||||
while (*kp == ' ')
|
||||
{
|
||||
@@ -1168,7 +1147,6 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
else if (*kp == ' ')
|
||||
{
|
||||
key_len--;
|
||||
kwarn=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1177,19 +1155,17 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key)
|
||||
}
|
||||
}
|
||||
*dp = '\0';
|
||||
if(kwarn)
|
||||
png_warning(png_ptr, "extra interior spaces removed from keyword");
|
||||
|
||||
if (key_len == 0)
|
||||
{
|
||||
png_free(png_ptr, *new_key);
|
||||
*new_key=NULL;
|
||||
png_warning(png_ptr, "Zero length keyword");
|
||||
png_chunk_warning(png_ptr, "Zero length keyword");
|
||||
}
|
||||
|
||||
if (key_len > 79)
|
||||
{
|
||||
png_warning(png_ptr, "keyword length must be 1 - 79 characters");
|
||||
png_chunk_warning(png_ptr, "keyword length must be 1 - 79 characters");
|
||||
new_key[79] = '\0';
|
||||
key_len = 79;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user