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.9beta9.tar
This commit is contained in:
47
pngwrite.c
47
pngwrite.c
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.2.9 March 9, 2006
|
||||
* Last changed in libpng 1.2.9 March 10, 2006
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2006 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -26,6 +26,8 @@ void PNGAPI
|
||||
png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_write_info_before_PLTE\n");
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE))
|
||||
{
|
||||
png_write_sig(png_ptr); /* write PNG signature */
|
||||
@@ -128,6 +130,9 @@ png_write_info(png_structp png_ptr, png_infop info_ptr)
|
||||
|
||||
png_debug(1, "in png_write_info\n");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_write_info_before_PLTE(png_ptr, info_ptr);
|
||||
|
||||
if (info_ptr->valid & PNG_INFO_PLTE)
|
||||
@@ -290,6 +295,8 @@ void PNGAPI
|
||||
png_write_end(png_structp png_ptr, png_infop info_ptr)
|
||||
{
|
||||
png_debug(1, "in png_write_end\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
if (!(png_ptr->mode & PNG_HAVE_IDAT))
|
||||
png_error(png_ptr, "No IDATs written into file");
|
||||
|
||||
@@ -617,6 +624,10 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf tmp_jmp; /* to save current jump buffer */
|
||||
#endif
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
@@ -694,6 +705,10 @@ png_write_rows(png_structp png_ptr, png_bytepp row,
|
||||
png_bytepp rp; /* row pointer */
|
||||
|
||||
png_debug(1, "in png_write_rows\n");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* loop through the rows */
|
||||
for (i = 0, rp = row; i < num_rows; i++, rp++)
|
||||
{
|
||||
@@ -711,6 +726,9 @@ png_write_image(png_structp png_ptr, png_bytepp image)
|
||||
int pass, num_pass; /* pass variables */
|
||||
png_bytepp rp; /* points to current row */
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_debug(1, "in png_write_image\n");
|
||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
/* intialize interlace handling. If image is not interlaced,
|
||||
@@ -734,8 +752,11 @@ png_write_image(png_structp png_ptr, png_bytepp image)
|
||||
void PNGAPI
|
||||
png_write_row(png_structp png_ptr, png_bytep row)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_debug2(1, "in png_write_row (row %ld, pass %d)\n",
|
||||
png_ptr->row_number, png_ptr->pass);
|
||||
|
||||
/* initialize transformations and other stuff if first time */
|
||||
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
||||
{
|
||||
@@ -909,6 +930,8 @@ void PNGAPI
|
||||
png_set_flush(png_structp png_ptr, int nrows)
|
||||
{
|
||||
png_debug(1, "in png_set_flush\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
|
||||
}
|
||||
|
||||
@@ -919,6 +942,8 @@ png_write_flush(png_structp png_ptr)
|
||||
int wrote_IDAT;
|
||||
|
||||
png_debug(1, "in png_write_flush\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
/* We have already written out all of the data */
|
||||
if (png_ptr->row_number >= png_ptr->num_rows)
|
||||
return;
|
||||
@@ -1095,6 +1120,8 @@ void PNGAPI
|
||||
png_set_filter(png_structp png_ptr, int method, int filters)
|
||||
{
|
||||
png_debug(1, "in png_set_filter\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(method == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
@@ -1203,6 +1230,8 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method,
|
||||
int i;
|
||||
|
||||
png_debug(1, "in png_set_filter_heuristics\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST)
|
||||
{
|
||||
png_warning(png_ptr, "Unknown filter heuristic method");
|
||||
@@ -1315,6 +1344,8 @@ void PNGAPI
|
||||
png_set_compression_level(png_structp png_ptr, int level)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_level\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL;
|
||||
png_ptr->zlib_level = level;
|
||||
}
|
||||
@@ -1323,6 +1354,8 @@ void PNGAPI
|
||||
png_set_compression_mem_level(png_structp png_ptr, int mem_level)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_mem_level\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL;
|
||||
png_ptr->zlib_mem_level = mem_level;
|
||||
}
|
||||
@@ -1331,6 +1364,8 @@ void PNGAPI
|
||||
png_set_compression_strategy(png_structp png_ptr, int strategy)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_strategy\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY;
|
||||
png_ptr->zlib_strategy = strategy;
|
||||
}
|
||||
@@ -1338,6 +1373,8 @@ png_set_compression_strategy(png_structp png_ptr, int strategy)
|
||||
void PNGAPI
|
||||
png_set_compression_window_bits(png_structp png_ptr, int window_bits)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
if (window_bits > 15)
|
||||
png_warning(png_ptr, "Only compression windows <= 32k supported by PNG");
|
||||
else if (window_bits < 8)
|
||||
@@ -1358,6 +1395,8 @@ void PNGAPI
|
||||
png_set_compression_method(png_structp png_ptr, int method)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_method\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
if (method != 8)
|
||||
png_warning(png_ptr, "Only compression method 8 is supported by PNG");
|
||||
png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_METHOD;
|
||||
@@ -1367,6 +1406,8 @@ png_set_compression_method(png_structp png_ptr, int method)
|
||||
void PNGAPI
|
||||
png_set_write_status_fn(png_structp png_ptr, png_write_status_ptr write_row_fn)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->write_row_fn = write_row_fn;
|
||||
}
|
||||
|
||||
@@ -1376,6 +1417,8 @@ png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
|
||||
write_user_transform_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_write_user_transform_fn\n");
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
png_ptr->transformations |= PNG_USER_TRANSFORM;
|
||||
png_ptr->write_user_transform_fn = write_user_transform_fn;
|
||||
}
|
||||
@@ -1387,6 +1430,8 @@ void PNGAPI
|
||||
png_write_png(png_structp png_ptr, png_infop info_ptr,
|
||||
int transforms, voidp params)
|
||||
{
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
|
||||
/* invert the alpha channel from opacity to transparency */
|
||||
if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
|
||||
|
||||
Reference in New Issue
Block a user