mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
6 Commits
v1.7.0beta
...
v1.7.0beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d23207b866 | ||
|
|
a70f5053de | ||
|
|
4cc89fb733 | ||
|
|
e966fac5ac | ||
|
|
cde9b583a8 | ||
|
|
1fd42d849d |
42
ANNOUNCE
42
ANNOUNCE
@@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.7.0beta79 - March 9, 2016
|
||||
Libpng 1.7.0beta80 - May 6, 2016
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
@@ -9,20 +9,20 @@ Files available for download:
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
1.7.0beta79.tar.xz (LZMA-compressed, recommended)
|
||||
1.7.0beta79.tar.gz
|
||||
1.7.0beta80.tar.xz (LZMA-compressed, recommended)
|
||||
1.7.0beta80.tar.gz
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
/scratch/glennrp/Libpng17/lp170b79.7z (LZMA-compressed, recommended)
|
||||
/scratch/glennrp/Libpng17/lp170b79.zip
|
||||
/scratch/glennrp/Libpng17/lp170b80.7z (LZMA-compressed, recommended)
|
||||
/scratch/glennrp/Libpng17/lp170b80.zip
|
||||
|
||||
Other information:
|
||||
|
||||
1.7.0beta79-README.txt
|
||||
1.7.0beta79-LICENSE.txt
|
||||
libpng-1.7.0beta79-*.asc (armored detached GPG signatures)
|
||||
1.7.0beta80-README.txt
|
||||
1.7.0beta80-LICENSE.txt
|
||||
libpng-1.7.0beta80-*.asc (armored detached GPG signatures)
|
||||
|
||||
Changes since the last public release (1.6.0):
|
||||
|
||||
@@ -1264,6 +1264,32 @@ Version 1.7.0beta79 [March 9, 2016]
|
||||
(Robert C. Seacord). Various other flags in png.h made unsigned as well.
|
||||
Fixed some misleading indentation (Krishnaraj Bhat).
|
||||
|
||||
Version 1.7.0beta80 [May 6, 2016]
|
||||
Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED
|
||||
Bug report by (Y.Ohashik).
|
||||
Quieted two Coverity issues in contrib/libtests/timepng.c.
|
||||
Write code update (John Bowler):
|
||||
Implemented better defaulting of zlib settings based on image properties.
|
||||
Replaced pngtest.png with one compressed with the new zlib settings.
|
||||
Implemented pass-through of png_write_rows when the rows can be used
|
||||
directly (a common case) optimizing the handling of previous-row
|
||||
buffering.
|
||||
Removed the METHODICAL filter selection method and disabled the HEURISTIC
|
||||
one. The first was ridiculously slow (though useful for experiments),
|
||||
and the second didn't work. Filter selection is temporarily disabled (it
|
||||
defaults to the lowest numbered filter in the list; typically 'none').
|
||||
New handling of compression settings (incomplete), new PNG compression level
|
||||
(not yet visible in an API).
|
||||
Back ported 'PNG_FAST_FILTERS' from 1.6 (in png.h).
|
||||
There are minimal API changes beyond removal of the selection options.
|
||||
Work is still to be done to investigate a filter selection mechanism that
|
||||
is at least as good as the previous one.
|
||||
Minor write bug-fixes, remove unimplemented code. A debug() assert
|
||||
fired if windowBits was set to 8 for the Huffman only and no-compression
|
||||
cases. This commit changes it to do some extra checking. Removed
|
||||
unreachable code in pz_default_settings and eliminated a spurious
|
||||
warning in pngcp for small files.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
26
CHANGES
26
CHANGES
@@ -5564,6 +5564,32 @@ Version 1.7.0beta79 [March 9, 2016]
|
||||
(Robert C. Seacord). Various other flags in png.h made unsigned as well.
|
||||
Fixed some misleading indentation (Krishnaraj Bhat).
|
||||
|
||||
Version 1.7.0beta80 [May 6, 2016]
|
||||
Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED
|
||||
Bug report by (Y.Ohashik).
|
||||
Quieted two Coverity issues in contrib/libtests/timepng.c.
|
||||
Write code update (John Bowler):
|
||||
Implemented better defaulting of zlib settings based on image properties.
|
||||
Replaced pngtest.png with one compressed with the new zlib settings.
|
||||
Implemented pass-through of png_write_rows when the rows can be used
|
||||
directly (a common case) optimizing the handling of previous-row
|
||||
buffering.
|
||||
Removed the METHODICAL filter selection method and disabled the HEURISTIC
|
||||
one. The first was ridiculously slow (though useful for experiments),
|
||||
and the second didn't work. Filter selection is temporarily disabled (it
|
||||
defaults to the lowest numbered filter in the list; typically 'none').
|
||||
New handling of compression settings (incomplete), new PNG compression level
|
||||
(not yet visible in an API).
|
||||
Back ported 'PNG_FAST_FILTERS' from 1.6 (in png.h).
|
||||
There are minimal API changes beyond removal of the selection options.
|
||||
Work is still to be done to investigate a filter selection mechanism that
|
||||
is at least as good as the previous one.
|
||||
Minor write bug-fixes, remove unimplemented code. A debug() assert
|
||||
fired if windowBits was set to 8 for the Huffman only and no-compression
|
||||
cases. This commit changes it to do some extra checking. Removed
|
||||
unreachable code in pz_default_settings and eliminated a spurious
|
||||
warning in pngcp for small files.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
@@ -697,7 +697,7 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(png PROPERTIES
|
||||
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta79
|
||||
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta80
|
||||
VERSION 17.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 17
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
4
LICENSE
4
LICENSE
@@ -10,7 +10,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta79, March 9, 2016, are
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta80, May 6, 2016, are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, and are distributed according to the same
|
||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
@@ -109,4 +109,4 @@ the additional disclaimers inserted at version 1.0.7.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
March 9, 2016
|
||||
May 6, 2016
|
||||
|
||||
2
README
2
README
@@ -1,4 +1,4 @@
|
||||
README for libpng version 1.7.0beta79 - March 9, 2016 (shared library 17.0)
|
||||
README for libpng version 1.7.0beta80 - May 6, 2016 (shared library 17.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
@@ -18,7 +18,7 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.7.0beta79],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.7.0beta80],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
@@ -40,7 +40,7 @@ dnl automake, so the following is not necessary (and is not defined anyway):
|
||||
dnl AM_PREREQ([1.11.2])
|
||||
dnl stop configure from automagically running automake
|
||||
|
||||
PNGLIB_VERSION=1.7.0beta79
|
||||
PNGLIB_VERSION=1.7.0beta80
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=7
|
||||
PNGLIB_RELEASE=0
|
||||
|
||||
@@ -328,6 +328,7 @@ struct display
|
||||
int bpp;
|
||||
png_byte ct;
|
||||
int no_warnings; /* Do not output libpng warnings */
|
||||
int min_windowBits; /* The windowBits range is 8..8 */
|
||||
|
||||
/* Options handling */
|
||||
png_uint_32 results; /* A mask of errors seen */
|
||||
@@ -389,6 +390,7 @@ display_init(struct display *dp)
|
||||
dp->read_pp = NULL;
|
||||
dp->ip = NULL;
|
||||
dp->write_pp = NULL;
|
||||
dp->min_windowBits = -1; /* this is an OPTIND, so -1 won't match anything */
|
||||
# if PNG_LIBPNG_VER < 10700
|
||||
dp->text_ptr = NULL;
|
||||
dp->num_text = 0;
|
||||
@@ -775,8 +777,12 @@ push_opt(struct display *dp, unsigned int sp, png_byte opt, int search)
|
||||
if (opt_list_end(dp, opt, entry))
|
||||
{
|
||||
dp->stack[sp].end = 1;
|
||||
display_log(dp, APP_WARNING, "%s: only testing one value",
|
||||
options[opt].name);
|
||||
/* Skip the warning if pngcp did this itself. See the code in
|
||||
* set_windowBits_hi.
|
||||
*/
|
||||
if (opt != dp->min_windowBits)
|
||||
display_log(dp, APP_WARNING, "%s: only testing one value",
|
||||
options[opt].name);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1193,8 +1199,8 @@ getsearchopts(struct display *dp, const char *opt_str, int *value)
|
||||
else if (opt == OPTIND(dp, windowBits))
|
||||
{
|
||||
/* Changing windowBits for strategies that do not search the window is
|
||||
* pointless. Huffman-only does not search, RLE only searchs backwards
|
||||
* one byte, so give that the maximum string length is 258, a windowBits
|
||||
* pointless. Huffman-only does not search, RLE only searches backwards
|
||||
* one byte, so given that the maximum string length is 258, a windowBits
|
||||
* of 9 is always sufficient.
|
||||
*/
|
||||
if (dp->value[istrat] == Z_HUFFMAN_ONLY)
|
||||
@@ -1609,10 +1615,10 @@ read_png(struct display *dp, const char *filename)
|
||||
png_alloc_size_t rb = png_get_rowbytes(dp->read_pp, dp->ip);
|
||||
|
||||
/* The size calc can overflow. */
|
||||
if (MAX_SIZE/rb < dp->h)
|
||||
if ((MAX_SIZE-dp->h)/rb < dp->h)
|
||||
png_error(dp->read_pp, "image too large");
|
||||
|
||||
dp->size = rb * dp->h;
|
||||
dp->size = rb * dp->h + dp->h/*filter byte*/;
|
||||
}
|
||||
|
||||
display_clean_read(dp);
|
||||
@@ -1826,18 +1832,28 @@ write_png(struct display *dp, const char *destname)
|
||||
static void
|
||||
set_windowBits_hi(struct display *dp)
|
||||
{
|
||||
/* windowBits is in the range 8..15, but it is said that setting '8'
|
||||
* prevents adequate search even if the image size is 256 bytes or less.
|
||||
/* windowBits is in the range 8..15 but zlib maps '8' to '9' so it is only
|
||||
* worth using if the data size is 256 byte or less.
|
||||
*/
|
||||
int wb = MAX_WBITS; /* for large images */
|
||||
int i = VLSIZE(windowBits_IDAT);
|
||||
|
||||
while (wb > 9 && dp->size <= 1U<<(wb-1)) --wb;
|
||||
while (wb > 8 && dp->size <= 1U<<(wb-1)) --wb;
|
||||
|
||||
while (--i >= 0) if (VLNAME(windowBits_IDAT)[i].name == range_hi) break;
|
||||
|
||||
assert(i > 0); /* vl_windowBits_IDAT always has a RANGE() */
|
||||
assert(i > 1); /* vl_windowBits_IDAT always has a RANGE() */
|
||||
VLNAME(windowBits_IDAT)[i].value = wb;
|
||||
|
||||
assert(VLNAME(windowBits_IDAT)[--i].name == range_lo);
|
||||
VLNAME(windowBits_IDAT)[i].value = wb > 8 ? 9 : 8;
|
||||
|
||||
/* If wb == 8 then any search has been restricted to just one windowBits
|
||||
* entry. Record that here to avoid producing a spurious app-level warning
|
||||
* above.
|
||||
*/
|
||||
if (wb == 8)
|
||||
dp->min_windowBits = OPTIND(dp, windowBits);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* timepng.c
|
||||
*
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
* Copyright (c) 2013,2016 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Last changed in libpng 1.6.22 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -10,15 +10,17 @@
|
||||
*
|
||||
* Load an arbitrary number of PNG files (from the command line, or, if there
|
||||
* are no arguments on the command line, from stdin) then run a time test by
|
||||
* reading each file by row. The test does nothing with the read result and
|
||||
* does no transforms. The only output is a time as a floating point number of
|
||||
* seconds with 9 decimal digits.
|
||||
* reading each file by row or by image (possibly with transforms in the latter
|
||||
* case). The only output is a time as a floating point number of seconds with
|
||||
* 9 decimal digits.
|
||||
*/
|
||||
#define _POSIX_C_SOURCE 199309L /* for clock_gettime */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
@@ -35,36 +37,61 @@
|
||||
# include "../../png.h"
|
||||
#endif
|
||||
|
||||
static int read_png(FILE *fp)
|
||||
/* The following is to support direct compilation of this file as C++ */
|
||||
#ifdef __cplusplus
|
||||
# define voidcast(type, value) static_cast<type>(value)
|
||||
#else
|
||||
# define voidcast(type, value) (value)
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if ((defined(PNG_SEQUENTIAL_READ_SUPPORTED)) && defined(PNG_STDIO_SUPPORTED)\
|
||||
&& defined(PNG_EASY_ACCESS_SUPPORTED) && defined(PNG_INFO_IMAGE_SUPPORTED))
|
||||
typedef struct
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytep row = NULL, display = NULL;
|
||||
FILE *input;
|
||||
FILE *output;
|
||||
} io_data;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
static PNG_CALLBACK(void, read_and_copy,
|
||||
(png_structp png_ptr, png_bytep buffer, png_size_t cb))
|
||||
{
|
||||
io_data *io = (io_data*)png_get_io_ptr(png_ptr);
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
if (fread(buffer, cb, 1, io->input) != 1)
|
||||
png_error(png_ptr, strerror(errno));
|
||||
|
||||
if (fwrite(buffer, cb, 1, io->output) != 1)
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
if (row != NULL) free(row);
|
||||
if (display != NULL) free(display);
|
||||
return 0;
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "temporary file PNG write failed\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
png_init_io(png_ptr, fp);
|
||||
static void read_by_row(png_structp png_ptr, png_infop info_ptr,
|
||||
FILE *write_ptr, FILE *read_ptr)
|
||||
{
|
||||
/* These don't get freed on error, this is fine; the program immediately
|
||||
* exits.
|
||||
*/
|
||||
png_bytep row = NULL, display = NULL;
|
||||
io_data io_copy;
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
if (info_ptr == NULL)
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
if (write_ptr != NULL)
|
||||
{
|
||||
/* Set up for a copy to the temporary file: */
|
||||
io_copy.input = read_ptr;
|
||||
io_copy.output = write_ptr;
|
||||
png_set_read_fn(png_ptr, &io_copy, read_and_copy);
|
||||
}
|
||||
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
{
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
row = malloc(rowbytes);
|
||||
display = malloc(rowbytes);
|
||||
row = voidcast(png_bytep,malloc(rowbytes));
|
||||
display = voidcast(png_bytep,malloc(rowbytes));
|
||||
|
||||
if (row == NULL || display == NULL)
|
||||
png_error(png_ptr, "OOM allocating row buffers");
|
||||
@@ -81,7 +108,8 @@ static int read_png(FILE *fp)
|
||||
png_uint_32 y = height;
|
||||
|
||||
/* NOTE: this trashes the row each time; interlace handling won't
|
||||
* work, but this avoids memory thrashing for speed testing.
|
||||
* work, but this avoids memory thrashing for speed testing and is
|
||||
* somewhat representative of an application that works row-by-row.
|
||||
*/
|
||||
while (y-- > 0)
|
||||
png_read_row(png_ptr, row, display);
|
||||
@@ -91,9 +119,51 @@ static int read_png(FILE *fp)
|
||||
|
||||
/* Make sure to read to the end of the file: */
|
||||
png_read_end(png_ptr, info_ptr);
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
|
||||
/* Free this up: */
|
||||
free(row);
|
||||
free(display);
|
||||
}
|
||||
|
||||
static PNG_CALLBACK(void, no_warnings, (png_structp png_ptr,
|
||||
png_const_charp warning))
|
||||
{
|
||||
(void)png_ptr;
|
||||
(void)warning;
|
||||
}
|
||||
|
||||
static int read_png(FILE *fp, png_int_32 transforms, FILE *write_file)
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,
|
||||
no_warnings);
|
||||
png_infop info_ptr = NULL;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
if (setjmp(png_jmpbuf(png_ptr)))
|
||||
{
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
png_set_benign_errors(png_ptr, 1/*allowed*/);
|
||||
# endif
|
||||
png_init_io(png_ptr, fp);
|
||||
|
||||
info_ptr = png_create_info_struct(png_ptr);
|
||||
|
||||
if (info_ptr == NULL)
|
||||
png_error(png_ptr, "OOM allocating info structure");
|
||||
|
||||
if (transforms < 0)
|
||||
read_by_row(png_ptr, info_ptr, write_file, fp);
|
||||
|
||||
else
|
||||
png_read_png(png_ptr, info_ptr, transforms, NULL/*params*/);
|
||||
|
||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -108,7 +178,7 @@ static int mytime(struct timespec *t)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int perform_one_test(FILE *fp, int nfiles)
|
||||
static int perform_one_test(FILE *fp, int nfiles, png_int_32 transforms)
|
||||
{
|
||||
int i;
|
||||
struct timespec before, after;
|
||||
@@ -120,7 +190,7 @@ static int perform_one_test(FILE *fp, int nfiles)
|
||||
{
|
||||
for (i=0; i<nfiles; ++i)
|
||||
{
|
||||
if (read_png(fp))
|
||||
if (read_png(fp, transforms, NULL/*write*/))
|
||||
{
|
||||
if (ferror(fp))
|
||||
{
|
||||
@@ -184,120 +254,343 @@ static int add_one_file(FILE *fp, char *name)
|
||||
|
||||
if (ip != NULL)
|
||||
{
|
||||
int ch;
|
||||
for (;;)
|
||||
/* Read the file using libpng; this detects errors and also deals with
|
||||
* files which contain data beyond the end of the file.
|
||||
*/
|
||||
int ok = 0;
|
||||
fpos_t pos;
|
||||
|
||||
if (fgetpos(fp, &pos))
|
||||
{
|
||||
ch = getc(ip);
|
||||
if (ch == EOF) break;
|
||||
putc(ch, fp);
|
||||
/* Fatal error reading the start: */
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "temporary file fgetpos error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ferror(ip))
|
||||
if (read_png(ip, -1/*by row*/, fp/*output*/))
|
||||
{
|
||||
perror(name);
|
||||
fprintf(stderr, "%s: read error\n", name);
|
||||
return 0;
|
||||
if (ferror(ip))
|
||||
{
|
||||
perror(name);
|
||||
fprintf(stderr, "%s: read error\n", name);
|
||||
}
|
||||
|
||||
else
|
||||
ok = 1; /* read ok */
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "%s: file not added\n", name);
|
||||
|
||||
(void)fclose(ip);
|
||||
|
||||
/* An error in the output is fatal; exit immediately: */
|
||||
if (ferror(fp))
|
||||
{
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "temporary file write error\n");
|
||||
return 0;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ok)
|
||||
return 1;
|
||||
|
||||
/* Did not read the file successfully, simply rewind the temporary
|
||||
* file. This must happen after the ferror check above to avoid clearing
|
||||
* the error.
|
||||
*/
|
||||
if (fsetpos(fp, &pos))
|
||||
{
|
||||
perror("temporary file");
|
||||
fprintf(stderr, "temporary file fsetpos error\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* file open error: */
|
||||
perror(name);
|
||||
fprintf(stderr, "%s: open failed\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0; /* file not added */
|
||||
}
|
||||
|
||||
static void
|
||||
usage(FILE *fp)
|
||||
{
|
||||
if (fp != NULL) fclose(fp);
|
||||
|
||||
fprintf(stderr,
|
||||
"Usage:\n"
|
||||
" timepng --assemble <assembly> {files}\n"
|
||||
" Read the files into <assembly>, output the count. Options are ignored.\n"
|
||||
" timepng --dissemble <assembly> <count> [options]\n"
|
||||
" Time <count> files from <assembly>, additional files may not be given.\n"
|
||||
" Otherwise:\n"
|
||||
" Read the files into a temporary file and time the decode\n"
|
||||
"Transforms:\n"
|
||||
" --by-image: read by image with png_read_png\n"
|
||||
" --<transform>: implies by-image, use PNG_TRANSFORM_<transform>\n"
|
||||
" Otherwise: read by row using png_read_row (to a single row buffer)\n"
|
||||
/* ISO C90 string length max 509 */);fprintf(stderr,
|
||||
"{files}:\n"
|
||||
" PNG files to copy into the assembly and time. Invalid files are skipped\n"
|
||||
" with appropriate error messages. If no files are given the list of files\n"
|
||||
" is read from stdin with each file name terminated by a newline\n"
|
||||
"Output:\n"
|
||||
" For --assemble the output is the name of the assembly file followed by the\n"
|
||||
" count of the files it contains; the arguments for --dissemble. Otherwise\n"
|
||||
" the output is the total decode time in seconds.\n");
|
||||
|
||||
exit(99);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ok = 0;
|
||||
FILE *fp = tmpfile();
|
||||
int err = 0;
|
||||
int nfiles = 0;
|
||||
int transforms = -1; /* by row */
|
||||
const char *assembly = NULL;
|
||||
FILE *fp;
|
||||
|
||||
if (fp != NULL)
|
||||
if (argc > 2 && strcmp(argv[1], "--assemble") == 0)
|
||||
{
|
||||
int err = 0;
|
||||
int nfiles = 0;
|
||||
|
||||
if (argc > 1)
|
||||
/* Just build the test file, argv[2] is the file name. */
|
||||
assembly = argv[2];
|
||||
fp = fopen(assembly, "wb");
|
||||
if (fp == NULL)
|
||||
{
|
||||
int i;
|
||||
perror(assembly);
|
||||
fprintf(stderr, "timepng --assemble %s: could not open for write\n",
|
||||
assembly);
|
||||
usage(NULL);
|
||||
}
|
||||
|
||||
for (i=1; i<argc; ++i)
|
||||
argv += 2;
|
||||
argc -= 2;
|
||||
}
|
||||
|
||||
else if (argc > 3 && strcmp(argv[1], "--dissemble") == 0)
|
||||
{
|
||||
fp = fopen(argv[2], "rb");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror(argv[2]);
|
||||
fprintf(stderr, "timepng --dissemble %s: could not open for read\n",
|
||||
argv[2]);
|
||||
usage(NULL);
|
||||
}
|
||||
|
||||
nfiles = atoi(argv[3]);
|
||||
if (nfiles <= 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"timepng --dissemble <file> <count>: %s is not a count\n",
|
||||
argv[3]);
|
||||
exit(99);
|
||||
}
|
||||
#ifdef __COVERITY__
|
||||
else
|
||||
{
|
||||
nfiles &= PNG_UINT_31_MAX;
|
||||
}
|
||||
#endif
|
||||
|
||||
argv += 3;
|
||||
argc -= 3;
|
||||
}
|
||||
|
||||
else /* Else use a temporary file */
|
||||
{
|
||||
#ifndef __COVERITY__
|
||||
fp = tmpfile();
|
||||
#else
|
||||
/* Experimental. Coverity says tmpfile() is insecure because it
|
||||
* generates predictable names.
|
||||
*
|
||||
* It is possible to satisfy Coverity by using mkstemp(); however,
|
||||
* any platform supporting mkstemp() undoubtedly has a secure tmpfile()
|
||||
* implementation as well, and doesn't need the fix. Note that
|
||||
* the fix won't work on platforms that don't support mkstemp().
|
||||
*
|
||||
* https://www.securecoding.cert.org/confluence/display/c/
|
||||
* FIO21-C.+Do+not+create+temporary+files+in+shared+directories
|
||||
* says that most historic implementations of tmpfile() provide
|
||||
* only a limited number of possible temporary file names
|
||||
* (usually 26) before file names are recycled. That article also
|
||||
* provides a secure solution that unfortunately depends upon mkstemp().
|
||||
*/
|
||||
char tmpfile[] = "timepng-XXXXXX";
|
||||
int filedes;
|
||||
umask(0177);
|
||||
filedes = mkstemp(tmpfile);
|
||||
if (filedes < 0)
|
||||
fp = NULL;
|
||||
else
|
||||
{
|
||||
fp = fdopen(filedes,"w+");
|
||||
/* Hide the filename immediately and ensure that the file does
|
||||
* not exist after the program ends
|
||||
*/
|
||||
(void) unlink(tmpfile);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
perror("tmpfile");
|
||||
fprintf(stderr, "timepng: could not open the temporary file\n");
|
||||
exit(1); /* not a user error */
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle the transforms: */
|
||||
while (argc > 1 && argv[1][0] == '-' && argv[1][1] == '-')
|
||||
{
|
||||
const char *opt = *++argv + 2;
|
||||
|
||||
--argc;
|
||||
|
||||
/* Transforms turn on the by-image processing and maybe set some
|
||||
* transforms:
|
||||
*/
|
||||
if (transforms == -1)
|
||||
transforms = PNG_TRANSFORM_IDENTITY;
|
||||
|
||||
if (strcmp(opt, "by-image") == 0)
|
||||
{
|
||||
/* handled above */
|
||||
}
|
||||
|
||||
# define OPT(name) else if (strcmp(opt, #name) == 0)\
|
||||
transforms |= PNG_TRANSFORM_ ## name
|
||||
|
||||
OPT(STRIP_16);
|
||||
OPT(STRIP_ALPHA);
|
||||
OPT(PACKING);
|
||||
OPT(PACKSWAP);
|
||||
OPT(EXPAND);
|
||||
OPT(INVERT_MONO);
|
||||
OPT(SHIFT);
|
||||
OPT(BGR);
|
||||
OPT(SWAP_ALPHA);
|
||||
OPT(SWAP_ENDIAN);
|
||||
OPT(INVERT_ALPHA);
|
||||
OPT(STRIP_FILLER);
|
||||
OPT(STRIP_FILLER_BEFORE);
|
||||
OPT(STRIP_FILLER_AFTER);
|
||||
OPT(GRAY_TO_RGB);
|
||||
OPT(EXPAND_16);
|
||||
OPT(SCALE_16);
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "timepng %s: unrecognized transform\n", opt);
|
||||
usage(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle the files: */
|
||||
if (argc > 1 && nfiles > 0)
|
||||
usage(fp); /* Additional files not valid with --dissemble */
|
||||
|
||||
else if (argc > 1)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=1; i<argc; ++i)
|
||||
{
|
||||
if (nfiles == INT_MAX)
|
||||
{
|
||||
if (add_one_file(fp, argv[i]))
|
||||
fprintf(stderr, "%s: skipped, too many files\n", argv[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
else if (add_one_file(fp, argv[i]))
|
||||
++nfiles;
|
||||
}
|
||||
}
|
||||
|
||||
else if (nfiles == 0) /* Read from stdin withoout --dissemble */
|
||||
{
|
||||
char filename[FILENAME_MAX+1];
|
||||
|
||||
while (fgets(filename, FILENAME_MAX+1, stdin))
|
||||
{
|
||||
size_t len = strlen(filename);
|
||||
|
||||
if (filename[len-1] == '\n')
|
||||
{
|
||||
filename[len-1] = 0;
|
||||
if (nfiles == INT_MAX)
|
||||
{
|
||||
fprintf(stderr, "%s: skipped, too many files\n", filename);
|
||||
break;
|
||||
}
|
||||
|
||||
else if (add_one_file(fp, filename))
|
||||
++nfiles;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "timepng: file name too long: ...%s\n",
|
||||
filename+len-32);
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(stdin))
|
||||
{
|
||||
fprintf(stderr, "timepng: stdin: read error\n");
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Perform the test, or produce the --assemble output: */
|
||||
if (!err)
|
||||
{
|
||||
if (nfiles > 0)
|
||||
{
|
||||
if (assembly != NULL)
|
||||
{
|
||||
if (fflush(fp) && !ferror(fp) && fclose(fp))
|
||||
{
|
||||
perror(assembly);
|
||||
fprintf(stderr, "%s: close failed\n", assembly);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
err = 1;
|
||||
break;
|
||||
printf("%s %d\n", assembly, nfiles);
|
||||
fflush(stdout);
|
||||
ok = !ferror(stdout);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ok = perform_one_test(fp, nfiles, transforms);
|
||||
(void)fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
char filename[FILENAME_MAX+1];
|
||||
|
||||
while (fgets(filename, FILENAME_MAX+1, stdin))
|
||||
{
|
||||
size_t len = strlen(filename);
|
||||
|
||||
if (filename[len-1] == '\n')
|
||||
{
|
||||
filename[len-1] = 0;
|
||||
if (add_one_file(fp, filename))
|
||||
++nfiles;
|
||||
|
||||
else
|
||||
{
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "timepng: truncated file name ...%s\n",
|
||||
filename+len-32);
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(stdin))
|
||||
{
|
||||
fprintf(stderr, "timepng: stdin: read error\n");
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!err)
|
||||
{
|
||||
if (nfiles > 0)
|
||||
ok = perform_one_test(fp, nfiles);
|
||||
|
||||
else
|
||||
fprintf(stderr, "usage: timepng {files} or ls files | timepng\n");
|
||||
}
|
||||
|
||||
(void)fclose(fp);
|
||||
usage(fp);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "timepng: could not open temporary file\n");
|
||||
(void)fclose(fp);
|
||||
|
||||
/* Exit code 0 on success. */
|
||||
return ok == 0;
|
||||
}
|
||||
#else /* !sufficient support */
|
||||
int main(void) { return 77; }
|
||||
#endif /* !sufficient support */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.7.0beta79 - March 9, 2016
|
||||
libpng version 1.7.0beta80 - May 6, 2016
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
@@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta79 - March 9, 2016
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta80 - May 6, 2016
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
@@ -5343,7 +5343,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.7.0beta79 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.7.0beta80 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
|
||||
18
libpng.3
18
libpng.3
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNG 3 "March 9, 2016"
|
||||
.TH LIBPNG 3 "May 6, 2016"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta79
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta80
|
||||
.SH SYNOPSIS
|
||||
\fB
|
||||
#include <png.h>\fP
|
||||
@@ -500,7 +500,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
|
||||
.SH LIBPNG.TXT
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.7.0beta79 - March 9, 2016
|
||||
libpng version 1.7.0beta80 - May 6, 2016
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
@@ -511,7 +511,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta79 - March 9, 2016
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta80 - May 6, 2016
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
|
||||
@@ -5843,7 +5843,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.7.0beta79 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.7.0beta80 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
@@ -5948,7 +5948,7 @@ the first widely used release:
|
||||
1.6.19rc01-03 16 10619 16.so.16.19[.0]
|
||||
...
|
||||
1.7.0alpha01-10 17 10700 17.so.17.0[.0]
|
||||
1.7.0beta01-79 17 10700 17.so.17.0[.0]
|
||||
1.7.0beta01-80 17 10700 17.so.17.0[.0]
|
||||
|
||||
Henceforth the source version will match the shared-library minor
|
||||
and patch numbers; the shared-library major version number will be
|
||||
@@ -6004,7 +6004,7 @@ possible without all of you.
|
||||
|
||||
Thanks to Frank J. T. Wojcik for helping with the documentation.
|
||||
|
||||
Libpng version 1.7.0beta79 - March 9, 2016:
|
||||
Libpng version 1.7.0beta80 - May 6, 2016:
|
||||
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
|
||||
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
|
||||
|
||||
@@ -6029,7 +6029,7 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta79, March 9, 2016, are
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.7.0beta80, May 6, 2016, are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, and are distributed according to the same
|
||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
@@ -6128,7 +6128,7 @@ the additional disclaimers inserted at version 1.0.7.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
March 9, 2016
|
||||
May 6, 2016
|
||||
|
||||
.\" end of man page
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.TH LIBPNGPF 3 "March 9, 2016"
|
||||
.TH LIBPNGPF 3 "May 6, 2016"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta79
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta80
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
|
||||
2
png.5
2
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "March 9, 2016"
|
||||
.TH PNG 5 "May 6, 2016"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
|
||||
6
png.c
6
png.c
@@ -15,7 +15,7 @@
|
||||
#define PNG_SRC_FILE PNG_SRC_FILE_png
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_7_0beta79 Your_png_h_is_not_version_1_7_0beta79;
|
||||
typedef png_libpng_version_1_7_0beta80 Your_png_h_is_not_version_1_7_0beta80;
|
||||
|
||||
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
||||
* of the PNG file signature. If the PNG data is embedded into another
|
||||
@@ -705,14 +705,14 @@ png_get_copyright(png_const_structrp png_ptr)
|
||||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.7.0beta79 - March 9, 2016" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.7.0beta80 - May 6, 2016" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
|
||||
PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||
PNG_STRING_NEWLINE;
|
||||
# else
|
||||
return "libpng version 1.7.0beta79 - March 9, 2016\
|
||||
return "libpng version 1.7.0beta80 - May 6, 2016\
|
||||
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
|
||||
72
png.h
72
png.h
@@ -1,7 +1,7 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.7.0beta79, March 9, 2016
|
||||
* libpng version 1.7.0beta80, May 6, 2016
|
||||
*
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
@@ -12,7 +12,7 @@
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.7.0beta79, March 9, 2016:
|
||||
* libpng versions 0.97, January 1998, through 1.7.0beta80, May 6, 2016:
|
||||
* Glenn Randers-Pehrson.
|
||||
* See also "Contributing Authors", below.
|
||||
*/
|
||||
@@ -25,7 +25,7 @@
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.0.7, July 1, 2000, through 1.7.0beta79, March 9, 2016, are
|
||||
* libpng versions 1.0.7, July 1, 2000, through 1.7.0beta80, May 6, 2016, are
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
||||
* derived from libpng-1.0.6, and are distributed according to the same
|
||||
* disclaimer and license as libpng-1.0.6 with the following individuals
|
||||
@@ -190,7 +190,7 @@
|
||||
* 1.6.19rc01-03 16 10619 16.so.16.19[.0]
|
||||
* ...
|
||||
* 1.7.0alpha01-10 17 10700 17.so.17.0[.0]
|
||||
* 1.7.0beta01-79 17 10700 17.so.17.0[.0]
|
||||
* 1.7.0beta01-80 17 10700 17.so.17.0[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
@@ -218,13 +218,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* March 9, 2016
|
||||
* May 6, 2016
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.7.0beta79 are Y2K compliant. It is my belief that
|
||||
* upward through 1.7.0beta80 are Y2K compliant. It is my belief that
|
||||
* earlier versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
@@ -286,9 +286,9 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.7.0beta79"
|
||||
#define PNG_LIBPNG_VER_STRING "1.7.0beta80"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.7.0beta79 - March 9, 2016\n"
|
||||
" libpng version 1.7.0beta80 - May 6, 2016\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 17
|
||||
#define PNG_LIBPNG_VER_DLLNUM 17
|
||||
@@ -302,7 +302,7 @@
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
*/
|
||||
|
||||
#define PNG_LIBPNG_VER_BUILD 79
|
||||
#define PNG_LIBPNG_VER_BUILD 80
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@@ -562,7 +562,7 @@ extern "C" {
|
||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_7_0beta79;
|
||||
typedef char* png_libpng_version_1_7_0beta80;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
@@ -1226,11 +1226,12 @@ PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],
|
||||
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
/* Convert from a struct tm to png_time */
|
||||
PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,
|
||||
const struct tm * ttime));
|
||||
PNG_EXPORT(24, PNG_DEPRECATED void, png_convert_from_struct_tm,
|
||||
(png_timep ptime, const struct tm * ttime));
|
||||
|
||||
/* Convert from time_t to png_time. Uses gmtime() */
|
||||
PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));
|
||||
PNG_EXPORT(25, PNG_DEPRECATED void, png_convert_from_time_t, (png_timep ptime,
|
||||
time_t ttime));
|
||||
#endif /* CONVERT_tIME */
|
||||
|
||||
#ifdef PNG_READ_EXPAND_SUPPORTED
|
||||
@@ -1533,7 +1534,7 @@ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
|
||||
#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */
|
||||
#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */
|
||||
/* Strip the second byte of information from a 16-bit depth file. */
|
||||
PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
|
||||
#endif
|
||||
@@ -1690,25 +1691,14 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
|
||||
* ignored if SUB is set; this is because these filter pairs are equivalent
|
||||
* when there is no previous row.
|
||||
*
|
||||
* 2) PNG_SELECT_FILTER_METHODICALLY_SUPPORTED:
|
||||
* If SELECT_FILTER_METHODICALLY is 'on' libpng tries all the filters in the
|
||||
* list and selects the one which gives the shortest compressed row, favoring
|
||||
* earlier filters.
|
||||
* 2) PNG_SELECT_FILTER_SUPPORTED:
|
||||
* libpng will buffer rows until enough data is available to perform a
|
||||
* reasonable filter selection heuristic then select filters for at least the
|
||||
* first buffered row.
|
||||
*
|
||||
* 3) PNG_SELECT_FILTER_HEURISTICALLY_SUPPORTED:
|
||||
* If SELECT_FILTER_HEURISTICALLY is 'on' libpng tests the start of each row
|
||||
* (a few thousand bytes at most) to see which filter is likely to produce
|
||||
* best compression.
|
||||
*
|
||||
* 4) If neither (2) nor (3) libpng selects the first filter in the list (there
|
||||
* is no warning that this will happen - check the #defines if you need to
|
||||
* know.)
|
||||
*
|
||||
* The seletion options are turned 'on' using png_set_option(method,
|
||||
* PNG_OPTION_ON) and turned off with PNG_OPTION_OFF. If a selection method is
|
||||
* turned off it will never be used, if neither option is turned on or off (i.e.
|
||||
* if png_set_option is not called) the first supported option (2) or (3) will
|
||||
* be used.
|
||||
* 3) !PNG_SELECT_FILTER_SUPPORTED:
|
||||
* libpng selects the first filter in the list (there is no warning that this
|
||||
* will happen - check the #defines if you need to know.)
|
||||
*
|
||||
* If you intend to use 'previous row' filters in an image set either the UP or
|
||||
* PAETH filter before the first call to png_write_row, depending on whether you
|
||||
@@ -1717,12 +1707,6 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
|
||||
* You can also select AVG on the first row; it uses half the value of the
|
||||
* preceding byte as a predictor and is not likely to have very good
|
||||
* performance.
|
||||
*
|
||||
* The SELECT_FILTER_METHODICALLY option is slow and memory intensive, but it is
|
||||
* almost certain to produce the smallest PNG file. Depending on the image data
|
||||
* the HEURISTIC option may improve results significantly over the NONE filter
|
||||
* and it has little overall effect on compression speed, however it can
|
||||
* sometimes produce larger files than not using any filtering.
|
||||
*/
|
||||
PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
|
||||
int filters));
|
||||
@@ -1752,12 +1736,12 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
|
||||
#define PNG_FILTER_AVG PNG_FILTER_MASK(PNG_FILTER_VALUE_AVG)
|
||||
#define PNG_FILTER_PAETH PNG_FILTER_MASK(PNG_FILTER_VALUE_PAETH)
|
||||
|
||||
/* Then two convenience values. PNG_NO_FILTERS is the same as
|
||||
/* Then three convenience values. PNG_NO_FILTERS is the same as
|
||||
* PNG_FILTER_VALUE_NONE, but this is harmless because they mean the same thing.
|
||||
*/
|
||||
#define PNG_NO_FILTERS 0x00
|
||||
#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
|
||||
PNG_FILTER_AVG | PNG_FILTER_PAETH)
|
||||
#define PNG_NO_FILTERS 0x00
|
||||
#define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP)
|
||||
#define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH)
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
|
||||
@@ -3629,9 +3613,7 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
|
||||
#define PNG_EXTENSIONS 0 /* BOTH: enable or disable extensions */
|
||||
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
|
||||
#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
|
||||
#define PNG_SELECT_FILTER_HEURISTICALLY 6 /* SOFTWARE: see png_set_filter */
|
||||
#define PNG_SELECT_FILTER_METHODICALLY 8 /* SOFTWARE: see png_set_filter */
|
||||
#define PNG_OPTION_NEXT 10 /* Next option - numbers must be even */
|
||||
#define PNG_OPTION_NEXT 6 /* Next option - numbers must be even */
|
||||
|
||||
/* Return values: NOTE: there are four values and 'off' is *not* zero */
|
||||
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.7.0beta79, March 9, 2016
|
||||
* libpng version 1.7.0beta80, May 6, 2016
|
||||
*
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
|
||||
31
pngpriv.h
31
pngpriv.h
@@ -1080,10 +1080,6 @@ PNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr,
|
||||
PNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr,
|
||||
png_const_voidp ptr, png_size_t length),PNG_EMPTY);
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* Write various chunks */
|
||||
|
||||
/* Write the IHDR chunk, and update the png_struct with the necessary
|
||||
@@ -1199,9 +1195,9 @@ PNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* Initialize the row compression mechanism. */
|
||||
PNG_INTERNAL_FUNCTION(void, png_write_start_IDAT, (png_structp png_ptr),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_start_IDAT,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
/* Do any required initialization before IDAT or row processing starts. */
|
||||
|
||||
/* Choose the best filter to use and filter the row data then write it out. If
|
||||
* WRITE_FILTERING is not supported this just writes the data out with a zero
|
||||
@@ -1215,10 +1211,11 @@ PNG_INTERNAL_FUNCTION(void, png_write_start_IDAT, (png_structp png_ptr),
|
||||
*/
|
||||
enum
|
||||
{
|
||||
png_row_end =0x1U, /* This is the last block in the row */
|
||||
png_pass_first_row =0x2U, /* This is the first row in a pass */
|
||||
png_pass_last_row =0x4U, /* This is the last row in a pass */
|
||||
png_pass_last =0x8U /* This is the last pass in the image */
|
||||
png_pass_last =0x1U, /* This is the last pass in the image */
|
||||
png_pass_last_row =0x2U, /* This is the last row in a pass */
|
||||
png_pass_first_row =0x4U, /* This is the first row in a pass */
|
||||
png_row_end =0x8U, /* This is the last block in the row */
|
||||
png_no_row_info =0x0U /* Placeholder */
|
||||
|
||||
/* A useful macro; return true if this is the last block of the last row in
|
||||
* the image.
|
||||
@@ -1226,11 +1223,21 @@ enum
|
||||
# define PNG_IDAT_END(f) (((f) & ~png_pass_first_row) == \
|
||||
(png_row_end+png_pass_last_row+png_pass_last))
|
||||
};
|
||||
PNG_INTERNAL_FUNCTION(void, png_write_filter_row, (png_structrp png_ptr,
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_png_data,(png_structrp png_ptr,
|
||||
png_bytep prev_pixels, png_const_bytep unfiltered_row, png_uint_32 x,
|
||||
unsigned int width/*pixels*/, unsigned int row_info_flags),
|
||||
PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_png_rows,(png_structrp png_ptr,
|
||||
png_const_bytep *rows, png_uint_32 num_rows), PNG_EMPTY);
|
||||
/* As above but rows[num_rows] of correctly (PNG) formated but unfiltered
|
||||
* data are passed in. For an interlaced image the rows will be interlaced
|
||||
* rows and therefore may be narrower than the image width.
|
||||
*
|
||||
* This function advances png_structp::pass and png_structp::row_number as
|
||||
* required.
|
||||
*/
|
||||
|
||||
/* Release memory used by the deflate mechanism */
|
||||
PNG_INTERNAL_FUNCTION(void, png_deflate_destroy, (png_structp png_ptr),
|
||||
PNG_EMPTY);
|
||||
|
||||
67
pngstruct.h
67
pngstruct.h
@@ -26,14 +26,14 @@
|
||||
#ifndef ZLIB_CONST
|
||||
/* We must ensure that zlib uses 'const' in declarations. */
|
||||
# define ZLIB_CONST
|
||||
#endif
|
||||
#endif /* !ZLIB_CONST */
|
||||
|
||||
#include PNG_ZLIB_HEADER
|
||||
|
||||
#ifdef const
|
||||
/* zlib.h sometimes #defines const to nothing, undo this. */
|
||||
# undef const
|
||||
#endif
|
||||
#endif /* const */
|
||||
|
||||
/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility
|
||||
* with older builds.
|
||||
@@ -41,10 +41,10 @@
|
||||
#if ZLIB_VERNUM < 0x1260
|
||||
# define PNGZ_MSG_CAST(s) png_constcast(char*,s)
|
||||
# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b)
|
||||
#else
|
||||
#else /* ZLIB_VERNUM >= 0x1260 */
|
||||
# define PNGZ_MSG_CAST(s) (s)
|
||||
# define PNGZ_INPUT_CAST(b) (b)
|
||||
#endif
|
||||
#endif /* ZLIB_VERNUM >= 0x1260 */
|
||||
|
||||
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
|
||||
* can handle at once. This type need be no larger than 16 bits (so maximum of
|
||||
@@ -57,17 +57,17 @@
|
||||
#ifndef ZLIB_IO_MAX
|
||||
# ifdef __COVERITY__
|
||||
# define ZLIB_IO_MAX ((uInt)255U) /* else COVERITY whines */
|
||||
# else
|
||||
# else /* !COVERITY */
|
||||
# define ZLIB_IO_MAX ((uInt)-1)
|
||||
# endif /* COVERITY */
|
||||
#endif
|
||||
# endif /* !COVERITY */
|
||||
#endif /* !ZLIB_IO_MAX */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* The write compression control (allocated on demand).
|
||||
* TODO: use this for the read state too.
|
||||
*/
|
||||
typedef struct png_zlib_state *png_zlib_statep;
|
||||
#endif
|
||||
#endif /* WRITE */
|
||||
|
||||
/* Colorspace support; structures used in png_struct, png_info and in internal
|
||||
* functions to hold and communicate information about the color space.
|
||||
@@ -114,13 +114,13 @@ typedef struct png_colorspace
|
||||
{
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
png_fixed_point gamma; /* File gamma */
|
||||
#endif
|
||||
#endif /* GAMMA */
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
png_xy end_points_xy; /* End points as chromaticities */
|
||||
png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
|
||||
png_uint_16 rendering_intent; /* Rendering intent of a profile */
|
||||
#endif
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
/* Flags are always defined to simplify the code. */
|
||||
png_uint_16 flags; /* As defined below */
|
||||
@@ -182,7 +182,7 @@ typedef struct
|
||||
* during PNG_TC_INIT_FINAL. The field is only used on read; write
|
||||
* transforms do not modify the gamma of the data.
|
||||
*/
|
||||
# endif
|
||||
# endif /* READ_GAMMA */
|
||||
unsigned int format; /* As pngstruct::row_format below */
|
||||
unsigned int range; /* Count of range transforms */
|
||||
# define PNG_TC_CHANNELS(tc) PNG_FORMAT_CHANNELS((tc).format)
|
||||
@@ -364,7 +364,7 @@ struct png_struct_def
|
||||
* accessed.)
|
||||
*/
|
||||
jmp_buf jmp_buf_local;
|
||||
#endif
|
||||
#endif /* SETJMP */
|
||||
|
||||
/* Next the frequently accessed fields. Many processors perform arithmetic
|
||||
* in the address pipeline, but frequently the amount of addition or
|
||||
@@ -420,7 +420,7 @@ struct png_struct_def
|
||||
/* Options */
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
png_uint_32 options; /* On/off state (up to 16 options) */
|
||||
#endif
|
||||
#endif /* SET_OPTIONS */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
@@ -428,13 +428,13 @@ struct png_struct_def
|
||||
* is in (just) the info_struct.
|
||||
*/
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
#endif /* COLORSPACE || GAMMA */
|
||||
#endif /* READ */
|
||||
|
||||
/* Transform handling */
|
||||
#ifdef PNG_TRANSFORM_MECH_SUPPORTED
|
||||
png_transformp transform_list; /* List of transformation to perform. */
|
||||
#endif
|
||||
#endif /* TRANSFORM_MECH */
|
||||
|
||||
/* ROW BUFFERS and CONTROL
|
||||
*
|
||||
@@ -442,9 +442,9 @@ struct png_struct_def
|
||||
* filter byte (which is in next_filter.) All fields are only used during
|
||||
* IDAT processing and start of 0.
|
||||
*/
|
||||
#if defined(PNG_WRITE_FILTER_SUPPORTED) || defined(PNG_READ_SUPPORTED)
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
png_bytep row_buffer; /* primary row buffer */
|
||||
#endif /* WRITE_FILTER || READ */
|
||||
#endif /* READ */
|
||||
#if (defined(PNG_PROGRESSIVE_READ_SUPPORTED) ||\
|
||||
defined(PNG_READ_INTERLACING_SUPPORTED)) &&\
|
||||
defined(PNG_TRANSFORM_MECH_SUPPORTED)
|
||||
@@ -482,10 +482,12 @@ struct png_struct_def
|
||||
unsigned int invalid_info; /* PNG_INFO_* for invalidated chunks */
|
||||
unsigned int palette_updated:1; /* png_struct::palette changed */
|
||||
#endif /* READ_TRANSFORMS */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
unsigned int write_rows :1; /* libpng has complete rows to write */
|
||||
#endif /* WRITE */
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
unsigned int read_started :1; /* at least one call to png_read_row */
|
||||
#endif
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
#if defined (PNG_READ_INTERLACING_SUPPORTED) ||\
|
||||
defined (PNG_WRITE_INTERLACING_SUPPORTED)
|
||||
unsigned int do_interlace :1; /* libpng handles the interlace */
|
||||
@@ -574,7 +576,7 @@ struct png_struct_def
|
||||
* available to zlib during read decompression.
|
||||
*/
|
||||
png_alloc_size_t read_buffer_size; /* current size of the buffer */
|
||||
#endif
|
||||
#endif /* READ */
|
||||
|
||||
#if defined(PNG_SEQUENTIAL_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
png_uint_32 IDAT_size; /* limit on IDAT read and write IDAT size */
|
||||
@@ -585,13 +587,13 @@ struct png_struct_def
|
||||
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
|
||||
png_longjmp_ptr longjmp_fn; /* setjmp non-local goto function. */
|
||||
size_t jmp_buf_size; /* size of *jmp_buf_ptr, if allocated */
|
||||
#endif
|
||||
#endif /* SETJMP */
|
||||
|
||||
/* Error/warning callbacks */
|
||||
png_error_ptr error_fn; /* print an error message and abort */
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
png_error_ptr warning_fn; /* print a warning and continue */
|
||||
#endif
|
||||
#endif /* WARNINGS */
|
||||
png_voidp error_ptr; /* user supplied data for the above */
|
||||
|
||||
/* MEMORY ALLOCATION */
|
||||
@@ -599,7 +601,7 @@ struct png_struct_def
|
||||
png_malloc_ptr malloc_fn; /* allocate memory */
|
||||
png_free_ptr free_fn; /* free memory */
|
||||
png_voidp mem_ptr; /* user supplied data for the above */
|
||||
#endif
|
||||
#endif /* USER_MEM */
|
||||
|
||||
/* IO and BASIC READ/WRITE SUPPORT */
|
||||
png_voidp io_ptr; /* user supplied data for IO callbacks */
|
||||
@@ -622,8 +624,7 @@ struct png_struct_def
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
||||
#endif
|
||||
|
||||
#endif /* WRITE_FLUSH */
|
||||
#endif /* WRITE */
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
@@ -634,14 +635,14 @@ struct png_struct_def
|
||||
* - it is decremented as memory is allocated.
|
||||
*/
|
||||
png_alloc_size_t user_chunk_malloc_max;
|
||||
#endif
|
||||
#endif /* SET_USER_LIMITS */
|
||||
#ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
/* limit on total *number* of sPLT, text and unknown chunks that can be
|
||||
* stored. 0 means unlimited. This field is a counter - it is decremented
|
||||
* as chunks are encountered.
|
||||
*/
|
||||
png_uint_32 user_chunk_cache_max;
|
||||
#endif
|
||||
#endif /* USER_LIMITS */
|
||||
|
||||
/* The progressive reader gets passed data and calls application handling
|
||||
* functions when appropriate.
|
||||
@@ -672,7 +673,7 @@ struct png_struct_def
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_uint_32 io_state; /* tells the app read/write progress */
|
||||
#endif
|
||||
#endif /* IO_STATE */
|
||||
|
||||
/* UNKNOWN CHUNK HANDLING */
|
||||
/* TODO: this is excessively complicated, there are multiple ways of doing
|
||||
@@ -686,12 +687,12 @@ struct png_struct_def
|
||||
* set_unknown_chunks interface.)
|
||||
*/
|
||||
png_voidp user_chunk_ptr;
|
||||
#endif
|
||||
#endif /* USER_CHUNKS */
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* This is called back from the unknown chunk handling */
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
#endif /* READ_USER_CHUNKS */
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
png_uint_32 known_unknown; /* Bit mask of known chunks to be treated as
|
||||
@@ -703,7 +704,7 @@ struct png_struct_def
|
||||
* 'known & ~save'.
|
||||
*/
|
||||
# define png_IDATs_skipped(pp) (((pp)->known_unknown & ~(pp)->save_unknown)&1U)
|
||||
#else
|
||||
#else /* !SAVE_UNKNOWN_CHUNKS */
|
||||
# define png_IDATs_skipped(pp) ((pp)->known_unknown & 1U)
|
||||
#endif /* !SAVE_UNKNOWN_CHUNKS */
|
||||
#endif /* HANDLE_AS_UNKNOWN */
|
||||
@@ -713,7 +714,7 @@ struct png_struct_def
|
||||
* followed by a PNG_HANDLE_* byte */
|
||||
unsigned int unknown_default :2; /* As PNG_HANDLE_* */
|
||||
unsigned int num_chunk_list; /* Number of entries in the list */
|
||||
#endif
|
||||
#endif /* SET_UNKNOWN_CHUNKS */
|
||||
|
||||
/* COMPRESSION AND DECOMPRESSION SUPPORT.
|
||||
*
|
||||
@@ -738,7 +739,7 @@ struct png_struct_def
|
||||
/* MNG SUPPORT */
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
unsigned int mng_features_permitted :3;
|
||||
#endif
|
||||
#endif /* MNG_FEATURES */
|
||||
|
||||
/* SCRATCH buffers, used when control returns to the application or a read
|
||||
* loop.
|
||||
|
||||
@@ -2070,4 +2070,4 @@ main(void)
|
||||
#endif
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_7_0beta79 Your_png_h_is_not_version_1_7_0beta79;
|
||||
typedef png_libpng_version_1_7_0beta80 Your_png_h_is_not_version_1_7_0beta80;
|
||||
|
||||
BIN
pngtest.png
BIN
pngtest.png
Binary file not shown.
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
11
pngwio.c
11
pngwio.c
@@ -67,18 +67,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function is called to output any data pending writing (normally
|
||||
* to disk). After png_flush is called, there should be no data pending
|
||||
* writing in any buffers.
|
||||
*/
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_flush(png_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr->output_flush_fn != NULL)
|
||||
png_ptr->output_flush_fn(png_ptr);
|
||||
}
|
||||
|
||||
# ifdef PNG_STDIO_SUPPORTED
|
||||
void PNGCBAPI
|
||||
png_default_flush(png_structp png_ptr)
|
||||
|
||||
416
pngwrite.c
416
pngwrite.c
@@ -487,7 +487,8 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
*/
|
||||
# ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
# ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED
|
||||
png_flush(png_ptr);
|
||||
if (png_ptr->output_flush_fn != NULL)
|
||||
png_ptr->output_flush_fn(png_ptr);
|
||||
# endif
|
||||
# endif
|
||||
}
|
||||
@@ -570,65 +571,6 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
}
|
||||
|
||||
|
||||
/* Write a few rows of image data. If the image is interlaced,
|
||||
* either you will have to write the 7 sub images, or, if you
|
||||
* have called png_set_interlace_handling(), you will have to
|
||||
* "write" the image seven times.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_write_rows(png_structrp png_ptr, png_bytepp row,
|
||||
png_uint_32 num_rows)
|
||||
{
|
||||
png_debug(1, "in png_write_rows");
|
||||
|
||||
if (png_ptr == NULL || row == NULL)
|
||||
return;
|
||||
|
||||
/* Loop through the rows */
|
||||
while (num_rows-- > 0)
|
||||
png_write_row(png_ptr, *row++);
|
||||
}
|
||||
|
||||
/* Write the image. You only need to call this function once, even
|
||||
* if you are writing an interlaced image.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_write_image(png_structrp png_ptr, png_bytepp image)
|
||||
{
|
||||
int num_pass; /* pass variables */
|
||||
|
||||
if (png_ptr == NULL || image == NULL)
|
||||
return;
|
||||
|
||||
png_debug(1, "in png_write_image");
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* Initialize interlace handling. If image is not interlaced,
|
||||
* this will set pass to 1
|
||||
*/
|
||||
num_pass = png_set_interlace_handling(png_ptr);
|
||||
#else
|
||||
num_pass = 1;
|
||||
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
png_app_error(png_ptr, "no interlace support");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Loop through passes */
|
||||
while (num_pass-- > 0)
|
||||
{
|
||||
png_bytepp rp = image; /* points to current row */
|
||||
png_uint_32 num_rows = png_ptr->height;
|
||||
|
||||
/* Loop through image */
|
||||
while (num_rows-- > 0)
|
||||
png_write_row(png_ptr, *rp++);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_INTERLACING_SUPPORTED) ||\
|
||||
defined(PNG_WRITE_TRANSFORMS_SUPPORTED)
|
||||
static void
|
||||
@@ -707,10 +649,10 @@ write_row_buffered(png_structrp png_ptr,
|
||||
}
|
||||
# endif /* WRITE_TRANSFORMS */
|
||||
|
||||
/* Call png_write_filter_row to write this block of data, the test on
|
||||
/* Call png_write_png_data to write this block of data, the test on
|
||||
* maxpixels says if this is the final block in the row.
|
||||
*/
|
||||
png_write_filter_row(png_ptr, prev_pixels, pixel_buffer.buffer, x,
|
||||
png_write_png_data(png_ptr, prev_pixels, pixel_buffer.buffer, x,
|
||||
max_pixels, row_info_flags);
|
||||
}
|
||||
}
|
||||
@@ -824,47 +766,7 @@ interlace_row_byte(png_const_structrp png_ptr, png_bytep dp, png_const_bytep sp,
|
||||
}
|
||||
#endif /* WRITE_INTERLACING */
|
||||
|
||||
static void
|
||||
write_row_unbuffered(png_structrp png_ptr, png_const_bytep row,
|
||||
unsigned int row_info_flags)
|
||||
{
|
||||
/* Split the row into blocks of the appropriate size: */
|
||||
const unsigned int input_depth = png_ptr->row_input_pixel_depth;
|
||||
unsigned int max_pixels = png_max_pixel_block(png_ptr);
|
||||
png_uint_32 max_bytes = max_pixels;
|
||||
const unsigned int pass = png_ptr->pass;
|
||||
const png_uint_32 width = png_ptr->interlaced == PNG_INTERLACE_NONE ?
|
||||
png_ptr->width : PNG_PASS_COLS(png_ptr->width, pass);
|
||||
png_uint_32 x;
|
||||
png_byte prev_pixels[4*2*2]; /* 2 pixels up to 4 2-byte channels each */
|
||||
|
||||
/* max_pixels is at most 16 bits, input_depth is at most 64, so the product
|
||||
* always fits in 32 bits:
|
||||
*/
|
||||
max_bytes *= input_depth; /* bits */
|
||||
debug(input_depth <= 64 && (max_bytes & 7U) == 0U);
|
||||
max_bytes >>= 3;
|
||||
|
||||
memset(prev_pixels, 0U, sizeof prev_pixels);
|
||||
|
||||
for (x = 0U; x < width; x += max_pixels, row += max_bytes)
|
||||
{
|
||||
if (max_pixels > width - x)
|
||||
{
|
||||
max_bytes = width - x;
|
||||
max_pixels = (unsigned int)/*SAFE*/max_bytes;
|
||||
max_bytes = (max_bytes * input_depth + 7U) >> 3;
|
||||
}
|
||||
|
||||
debug((row_info_flags & png_row_end) == 0U); /* must be set here at end */
|
||||
if (x + max_pixels >= width)
|
||||
row_info_flags |= png_row_end;
|
||||
|
||||
png_write_filter_row(png_ptr, prev_pixels, row, x, max_pixels,
|
||||
row_info_flags);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
static void
|
||||
write_row_core(png_structrp png_ptr, png_const_bytep row,
|
||||
unsigned int row_info_flags)
|
||||
@@ -880,7 +782,8 @@ write_row_core(png_structrp png_ptr, png_const_bytep row,
|
||||
/* If control reaches this point the intermediate buffer is not required and
|
||||
* the input data can be used unmodified.
|
||||
*/
|
||||
write_row_unbuffered(png_ptr, row, row_info_flags);
|
||||
png_write_png_rows(png_ptr, &row, 1U);
|
||||
PNG_UNUSED(row_info_flags)
|
||||
}
|
||||
|
||||
/* Write a single non-interlaced row. */
|
||||
@@ -888,75 +791,53 @@ static void
|
||||
write_row_non_interlaced(png_structrp png_ptr, png_const_bytep row)
|
||||
{
|
||||
const png_uint_32 row_number = png_ptr->row_number+1U;
|
||||
const int last_pass_row = row_number == png_ptr->height;
|
||||
|
||||
/* There is only one pass, so this is the last pass: */
|
||||
write_row_core(png_ptr, row,
|
||||
(row_number == 1U ? png_pass_first_row : 0) |
|
||||
(last_pass_row ? png_pass_last_row : 0) |
|
||||
png_pass_last);
|
||||
const unsigned int row_info_flags =
|
||||
(row_number == 1U ? png_pass_first_row : 0) |
|
||||
(row_number >= png_ptr->height ? png_pass_last_row : 0) |
|
||||
png_pass_last;
|
||||
|
||||
if (!last_pass_row)
|
||||
png_ptr->row_number = row_number;
|
||||
debug(png_ptr->interlaced == PNG_INTERLACE_NONE);
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->row_number = 0U;
|
||||
png_ptr->pass = 7U;
|
||||
}
|
||||
write_row_core(png_ptr, row, row_info_flags);
|
||||
}
|
||||
|
||||
/* Write a single interlaced row. */
|
||||
static void
|
||||
write_row_interlaced(png_structrp png_ptr, png_const_bytep row)
|
||||
{
|
||||
/* row_number is the row in the pass. The app must only call png_write_row
|
||||
* the correct number of times. 'pass' is set to 7U after the end.
|
||||
*/
|
||||
const png_uint_32 row_number = png_ptr->row_number+1U;
|
||||
unsigned int pass = png_ptr->pass;
|
||||
const int last_pass_row = row_number == PNG_PASS_ROWS(png_ptr->height, pass);
|
||||
const png_uint_32 height = png_ptr->height;
|
||||
const unsigned int pass = png_ptr->pass;
|
||||
const unsigned int row_info_flags =
|
||||
(row_number == 1U ? png_pass_first_row : 0) |
|
||||
(row_number == PNG_PASS_ROWS(height, pass) ? png_pass_last_row : 0) |
|
||||
(pass == PNG_LAST_PASS(png_ptr->width, height) ? png_pass_last : 0);
|
||||
|
||||
write_row_core(png_ptr, row,
|
||||
(row_number == 1U ? png_pass_first_row : 0) |
|
||||
(last_pass_row ? png_pass_last_row : 0) |
|
||||
(pass == PNG_LAST_PASS(png_ptr->width, png_ptr->height) ?
|
||||
png_pass_last : 0));
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* Check that libpng is not doing the interlace: */
|
||||
debug(png_ptr->interlaced != PNG_INTERLACE_NONE &&
|
||||
!png_ptr->do_interlace);
|
||||
# endif /* WRITE_INTERLACING */
|
||||
|
||||
if (!last_pass_row)
|
||||
png_ptr->row_number = row_number;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->row_number = 0U;
|
||||
|
||||
do
|
||||
++pass;
|
||||
while (pass < 7U &&
|
||||
!PNG_PASS_IN_IMAGE(png_ptr->width, png_ptr->height, pass));
|
||||
|
||||
png_ptr->pass = 0x7U & pass;
|
||||
}
|
||||
write_row_core(png_ptr, row, row_info_flags);
|
||||
}
|
||||
#endif /* WRITE_TRANSFORMS */
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* Interlace a row then write it out. */
|
||||
static int
|
||||
static void
|
||||
interlace_row(png_structrp png_ptr, png_const_bytep row)
|
||||
{
|
||||
/* row_number is in the image, it may not be in the pass and, likewise, the
|
||||
* pass may not exist.
|
||||
*/
|
||||
/* The row may not exist in the image (for this pass). */
|
||||
const png_uint_32 row_number = png_ptr->row_number; /* in image */
|
||||
const unsigned int pass = png_ptr->pass;
|
||||
const int write_row = png_ptr->width > PNG_PASS_START_COL(pass) &&
|
||||
PNG_ROW_IN_INTERLACE_PASS(row_number, pass);
|
||||
|
||||
if (write_row)
|
||||
if (png_ptr->width > PNG_PASS_START_COL(pass) &&
|
||||
PNG_ROW_IN_INTERLACE_PASS(row_number, pass))
|
||||
{
|
||||
const unsigned int row_info_flags =
|
||||
(row_number == PNG_PASS_START_ROW(pass) ?
|
||||
png_pass_first_row : 0) |
|
||||
(row_number == PNG_PASS_START_ROW(pass) ? png_pass_first_row : 0) |
|
||||
(PNG_LAST_PASS_ROW(row_number, pass, png_ptr->height) ?
|
||||
png_pass_last_row : 0) |
|
||||
(pass == PNG_LAST_PASS(png_ptr->width, png_ptr->height) ?
|
||||
@@ -991,79 +872,214 @@ interlace_row(png_structrp png_ptr, png_const_bytep row)
|
||||
interlace_row_byte, input_depth >> 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* pass < 6 */
|
||||
|
||||
else /* pass 6; no interlacing required */
|
||||
else /* pass 6: no interlacing required */
|
||||
write_row_core(png_ptr, row, row_info_flags);
|
||||
}
|
||||
|
||||
if (row_number+1U < png_ptr->height)
|
||||
png_ptr->row_number = row_number+1U;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->row_number = 0U;
|
||||
png_ptr->pass = 0x7U & (pass+1U);
|
||||
}
|
||||
/* This code must advance row_number/pass itself; the row has been
|
||||
* skipped.
|
||||
*/
|
||||
if (row_number+1U < png_ptr->height)
|
||||
png_ptr->row_number = row_number+1U;
|
||||
|
||||
return write_row;
|
||||
else
|
||||
{
|
||||
png_ptr->row_number = 0U;
|
||||
png_ptr->pass = 0x7U & (pass+1U);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_INTERLACING */
|
||||
|
||||
/* Called by user to write a row of image data */
|
||||
void PNGAPI
|
||||
png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
/* Bottleneck API to actually write a number of rows, only exists because the
|
||||
* rows parameter to png_write_rows is wrong.
|
||||
*/
|
||||
static void
|
||||
png_write_rows_internal(png_structrp png_ptr, png_const_bytep *rows,
|
||||
png_uint_32 num_rows)
|
||||
{
|
||||
if (png_ptr != NULL)
|
||||
if (png_ptr != NULL && num_rows > 0U && rows != NULL)
|
||||
{
|
||||
const unsigned int pass = png_ptr->pass;
|
||||
const png_uint_32 row_number = png_ptr->row_number;
|
||||
|
||||
/* Unlike the read code initialization happens automatically: */
|
||||
if (row_number == 0 && pass == 0)
|
||||
png_write_start_IDAT(png_ptr); /* doesn't change row/pass/width */
|
||||
if (png_ptr->row_number == 0U && png_ptr->pass == 0U)
|
||||
{
|
||||
png_init_row_info(png_ptr);
|
||||
|
||||
else if (pass == 7U) /* too many calls; write already ended */
|
||||
# ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* If the app takes a png_info from a read operation and if the app has
|
||||
* performed transforms on the data the png_info can contain IHDR
|
||||
* information that cannot be represented in PNG. The code that writes
|
||||
* the IHDR takes the color type from the png_info::format. The app
|
||||
* adds transforms, before or after writing the IHDR, then the IHDR
|
||||
* color_type stored in png_struct::color_type is used in
|
||||
* png_init_row_info above to work out the actual row format.
|
||||
*
|
||||
* Prior to 1.7.0 this was not verified (there was no easy way to do
|
||||
* so). Now we can check it here, however this is an:
|
||||
*
|
||||
* API CHANGE: in 1.7.0 an error may be flagged against bogus
|
||||
* info_struct formats even though the app had removed them itself.
|
||||
* It's just a warning at present.
|
||||
*
|
||||
* The test is that either the row_format produced by the write
|
||||
* transforms exactly matches that in the original info_struct::format
|
||||
* or that the info_struct::format was a simple mapping of the
|
||||
* color_type that ended up in the IHDR:
|
||||
*/
|
||||
if (png_ptr->row_format != png_ptr->info_format &&
|
||||
PNG_FORMAT_FROM_COLOR_TYPE(png_ptr->color_type) !=
|
||||
png_ptr->info_format)
|
||||
png_app_warning(png_ptr, "info_struct format does not match IHDR");
|
||||
# endif /* WRITE_TRANSFORMS */
|
||||
|
||||
/* Perform initialization required before IDATs are written. */
|
||||
png_write_start_IDAT(png_ptr);
|
||||
}
|
||||
|
||||
else if (png_ptr->pass >= 7U) /* too many calls; write already ended */
|
||||
{
|
||||
debug(png_ptr->row_number == 0U);
|
||||
png_app_error(png_ptr, "Too many calls to png_write_row");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Make sure there is a row to write: */
|
||||
if (row == NULL)
|
||||
{
|
||||
png_app_error(png_ptr, "NULL row pointer to png_write_row");
|
||||
return;
|
||||
}
|
||||
|
||||
if (png_ptr->interlaced == PNG_INTERLACE_NONE)
|
||||
write_row_non_interlaced(png_ptr, row);
|
||||
/* The remainder of these tests detect internal errors in libpng */
|
||||
else if (png_ptr->interlaced == PNG_INTERLACE_NONE)
|
||||
affirm(png_ptr->row_number < png_ptr->height && png_ptr->pass == 0U);
|
||||
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* Optional: libpng does the interlacing, app passes every row of the
|
||||
* image the required number of times.
|
||||
*/
|
||||
else if (png_ptr->do_interlace != 0U)
|
||||
{
|
||||
if (!interlace_row(png_ptr, row))
|
||||
return; /* row skipped; skip the write callback */
|
||||
}
|
||||
# endif
|
||||
else if (png_ptr->do_interlace)
|
||||
affirm(png_ptr->row_number < png_ptr->height);
|
||||
# endif /* WRITE_INTERLACING */
|
||||
|
||||
else /* app does the interlacing */
|
||||
write_row_interlaced(png_ptr, row);
|
||||
else /* app does interlace */
|
||||
affirm(
|
||||
PNG_PASS_IN_IMAGE(png_ptr->width, png_ptr->height, png_ptr->pass) &&
|
||||
png_ptr->row_number < PNG_PASS_ROWS(png_ptr->height, png_ptr->pass)
|
||||
);
|
||||
|
||||
/* API CHANGE: 1.7.0: this is now called after png_struct::row_number and
|
||||
* png_struct::pass have been updated and, at the end of the image, after
|
||||
* the deflate stream has been closed. The order of the call with respect
|
||||
* to the flush operation has also changed. The callback can't discover
|
||||
* any of this unless it relies on the write callbacks to find the row
|
||||
* data, and that was never predictable.
|
||||
/* First handle rows that require buffering because of the need to
|
||||
* interlace them or the need to perform write transforms.
|
||||
*/
|
||||
if (png_ptr->write_row_fn != NULL)
|
||||
(*(png_ptr->write_row_fn))(png_ptr, row_number, pass);
|
||||
} /* png_ptr != NULL */
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
/* libpng is doing the interlacing, but this only makes a difference to
|
||||
* the first six passes (numbered, in libpng, 0..5); the seventh pass
|
||||
* (numbered 6 by libpng) consists of complete image rows.
|
||||
*/
|
||||
if (png_ptr->do_interlace) while (num_rows > 0U && png_ptr->pass < 6)
|
||||
interlace_row(png_ptr, *rows++), --num_rows;
|
||||
# endif /* WRITE_INTERLACING */
|
||||
|
||||
# ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
|
||||
/* Transforms required however the row interlacing has already been
|
||||
* handled and we have a complete (PNG) row.
|
||||
*/
|
||||
if (png_ptr->transform_list != NULL)
|
||||
{
|
||||
if (png_ptr->interlaced == PNG_INTERLACE_NONE)
|
||||
while (num_rows > 0U)
|
||||
write_row_non_interlaced(png_ptr, *rows++), --num_rows;
|
||||
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
else if (png_ptr->do_interlace)
|
||||
while (num_rows > 0U)
|
||||
interlace_row(png_ptr, *rows++), --num_rows;
|
||||
# endif /* WRITE_INTERLACING */
|
||||
|
||||
else /* app does the interlacing */
|
||||
while (num_rows > 0U)
|
||||
write_row_interlaced(png_ptr, *rows++), --num_rows;
|
||||
}
|
||||
# endif /* WRITE_TRANSFORMS */
|
||||
|
||||
/* Finally handle any remaining rows that require no (libpng) interlace
|
||||
* and no transforms.
|
||||
*/
|
||||
if (num_rows > 0U)
|
||||
png_write_png_rows(png_ptr, rows, num_rows);
|
||||
|
||||
/* Repeat the checks above, but allow for end-of-image. */
|
||||
if (png_ptr->pass < 7U)
|
||||
{
|
||||
if (png_ptr->interlaced == PNG_INTERLACE_NONE)
|
||||
affirm(png_ptr->row_number < png_ptr->height &&
|
||||
png_ptr->pass == 0U);
|
||||
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
else if (png_ptr->do_interlace)
|
||||
affirm(png_ptr->row_number < png_ptr->height);
|
||||
# endif /* WRITE_INTERLACING */
|
||||
|
||||
else /* app does interlace */
|
||||
affirm(PNG_PASS_IN_IMAGE(png_ptr->width, png_ptr->height,
|
||||
png_ptr->pass) &&
|
||||
png_ptr->row_number <
|
||||
PNG_PASS_ROWS(png_ptr->height, png_ptr->pass));
|
||||
}
|
||||
} /* png_ptr, rows, num_rows all valid */
|
||||
|
||||
else if (png_ptr != NULL)
|
||||
png_app_warning(png_ptr, "Missing rows to row write API");
|
||||
}
|
||||
|
||||
/* ROW WRITE APIs */
|
||||
/* Called by user to write a single row of image data */
|
||||
void PNGAPI
|
||||
png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
{
|
||||
png_debug(1, "in png_write_row");
|
||||
png_write_rows_internal(png_ptr, &row, 1U);
|
||||
}
|
||||
|
||||
/* Write a few rows of image data. If the image is interlaced,
|
||||
* either you will have to write the 7 sub images, or, if you
|
||||
* have called png_set_interlace_handling(), you will have to
|
||||
* "write" the image seven times.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_write_rows(png_structrp png_ptr, png_bytepp rows, png_uint_32 num_rows)
|
||||
{
|
||||
png_debug(1, "in png_write_rows");
|
||||
|
||||
if (png_ptr != NULL)
|
||||
png_write_rows_internal(png_ptr, png_constcast(png_const_bytep*,rows),
|
||||
num_rows);
|
||||
}
|
||||
|
||||
/* Write the image. You only need to call this function once, even
|
||||
* if you are writing an interlaced image.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_write_image(png_structrp png_ptr, png_bytepp image)
|
||||
{
|
||||
png_debug(1, "in png_write_image");
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
int num_pass = 1;
|
||||
|
||||
/* The image is always an non-interlaced image. To write it as interlaced
|
||||
* interlace handling must be present:
|
||||
*/
|
||||
if (png_ptr->interlaced)
|
||||
{
|
||||
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
num_pass = png_set_interlace_handling(png_ptr);
|
||||
# else /* !WRITE_INTERLACING */
|
||||
/* There is no recovery because the IHDR has already been written.
|
||||
*/
|
||||
png_error(png_ptr, "No interlace support");
|
||||
# endif /* !WRITE_INTERLACING */
|
||||
}
|
||||
|
||||
/* And write the whole thing, 7 times if interlacing it: */
|
||||
for (; num_pass > 0; --num_pass)
|
||||
png_write_rows(png_ptr, image, png_ptr->height);
|
||||
}
|
||||
}
|
||||
|
||||
/* Free any memory used in png_ptr struct without freeing the struct itself. */
|
||||
@@ -1074,10 +1090,6 @@ png_write_destroy(png_structrp png_ptr)
|
||||
|
||||
png_deflate_destroy(png_ptr);
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->row_buffer);
|
||||
png_ptr->row_buffer = NULL;
|
||||
#endif /* WRITE_FILTER */
|
||||
#ifdef PNG_TRANSFORM_MECH_SUPPORTED
|
||||
png_transform_free(png_ptr, &png_ptr->transform_list);
|
||||
#endif
|
||||
|
||||
2461
pngwutil.c
2461
pngwutil.c
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
|
||||
VisualStudio instructions
|
||||
|
||||
libpng version 1.7.0beta79 - March 9, 2016
|
||||
libpng version 1.7.0beta80 - May 6, 2016
|
||||
|
||||
Copyright (c) 2010,2013,2015 Glenn Randers-Pehrson
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
* zlib.props - location of zlib source
|
||||
*
|
||||
* libpng version 1.7.0beta79 - March 9, 2016
|
||||
* libpng version 1.7.0beta80 - May 6, 2016
|
||||
*
|
||||
* Copyright (c) 2011,2013,2014 Glenn Randers-Pehrson
|
||||
*
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Makefiles for libpng version 1.7.0beta79 - March 9, 2016
|
||||
Makefiles for libpng version 1.7.0beta80 - May 6, 2016
|
||||
|
||||
pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng17.so.17.1.7.0beta79)
|
||||
(gcc, creates libpng17.so.17.1.7.0beta80)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
@@ -33,12 +33,12 @@ pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.sggcc => Silicon Graphics (gcc,
|
||||
creates libpng17.so.17.1.7.0beta79)
|
||||
creates libpng17.so.17.1.7.0beta80)
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc,
|
||||
creates libpng17.so.17.1.7.0beta79)
|
||||
creates libpng17.so.17.1.7.0beta80)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng17.so.17.1.7.0beta79)
|
||||
creates libpng17.so.17.1.7.0beta80)
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
|
||||
@@ -21,7 +21,7 @@ PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
|
||||
PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
|
||||
PNG_DFN ""
|
||||
PNG_DFN "EXPORTS"
|
||||
PNG_DFN ";Version 1.7.0beta79"
|
||||
PNG_DFN ";Version 1.7.0beta80"
|
||||
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.7.0beta79
|
||||
version=1.7.0beta80
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
||||
@@ -5,6 +5,6 @@ includedir=@includedir@/libpng17
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.7.0beta79
|
||||
Version: 1.7.0beta80
|
||||
Libs: -L${libdir} -lpng17
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng17
|
||||
|
||||
LIB= png17
|
||||
SHLIB_MAJOR= 0
|
||||
SHLIB_MINOR= 1.7.0beta79
|
||||
SHLIB_MINOR= 1.7.0beta80
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include
|
||||
|
||||
LIB= png
|
||||
SHLIB_MAJOR= 17
|
||||
SHLIB_MINOR= 1.7.0beta79
|
||||
SHLIB_MINOR= 1.7.0beta80
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -11,7 +11,7 @@ LIBDIR= ${PREFIX}/lib
|
||||
MANDIR= ${PREFIX}/man/cat
|
||||
|
||||
SHLIB_MAJOR= 17
|
||||
SHLIB_MINOR= 1.7.0beta79
|
||||
SHLIB_MINOR= 1.7.0beta80
|
||||
|
||||
LIB= png
|
||||
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \
|
||||
|
||||
@@ -930,20 +930,36 @@ option CONVERT_tIME requires WRITE_ANCILLARY_CHUNKS
|
||||
# png_set_filter interface allowing the application to select the filter
|
||||
# used for each row.
|
||||
#
|
||||
# SELECT_FILTER_HEURISTICALLY
|
||||
# Enables code to cause libpng to choose a filter from a set passed to
|
||||
# png_set_filter. Without this code libpng just chooses the first filter in
|
||||
# the list if multiple are given.
|
||||
# SELECT_FILTER
|
||||
# Enables code to select between multiple filters on write. Without this
|
||||
# the 'first' (lowest numbered) filter will be selected an this typically
|
||||
# works out as PNG_FILTER_VALUE_NONE.
|
||||
#
|
||||
# SELECT_FILTER_METHODICALLY
|
||||
# Enables code to try all the filters in the list passed to png_set_filter
|
||||
# and choose the one which results in the least number of compressed bytes
|
||||
# added by the current row.
|
||||
# COMPRESSION_BUFFER_MAX
|
||||
# WARNING: take care if you set this. This is the maximum amount of input
|
||||
# data that the implementation of deflate can consume before it outputs a
|
||||
# Huffman table for that data. I.e. before it commits to an encoding of the
|
||||
# data it has read. This is used solely to implement a limit on the amount
|
||||
# of image data buffering that occurs inside libpng before filter selection
|
||||
# is done. Normally the limit is never reached because of the next setting,
|
||||
# but this is a compile time limit and it is intended to prevent a potential
|
||||
# DNS service as a result of an application setting the libpng equivalent of
|
||||
# volume level 11 (read the wikipedia article on "Up to eleven").
|
||||
#
|
||||
# NOTE: the image of a black cat in a coal mine obviously requires this
|
||||
# limit, but some more valid images can get very close; well over 8MByte.
|
||||
#
|
||||
# COMPRESSION_BUFFER_LIMIT
|
||||
# This is the (overrideable) default for the amount of memory libpng will
|
||||
# buffer before selecting a filter for a row. It is limited itself to
|
||||
# COMPRESSION_BUFFER_MAX as values above that level make no change (see the
|
||||
# previous paragraph.)
|
||||
#
|
||||
# See png.h for more description of these options.
|
||||
option WRITE_FILTER requires WRITE
|
||||
option SELECT_FILTER_HEURISTICALLY requires WRITE_FILTER enables SET_OPTION
|
||||
option SELECT_FILTER_METHODICALLY requires WRITE_FILTER enables SET_OPTION
|
||||
option SELECT_FILTER requires WRITE_FILTER disabled
|
||||
setting COMPRESSION_BUFFER_MAX default 8453377
|
||||
setting COMPRESSION_BUFFER_LIMIT default 8453377
|
||||
|
||||
# added at libpng-1.5.4
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* libpng 1.7.0beta79 STANDARD API DEFINITION */
|
||||
/* libpng 1.7.0beta80 STANDARD API DEFINITION */
|
||||
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* Libpng version 1.7.0beta79, March 9, 2016 */
|
||||
/* libpng version 1.7.0beta80, May 6, 2016 */
|
||||
|
||||
/* Copyright (c) 1998-2016 Glenn Randers-Pehrson */
|
||||
|
||||
@@ -100,8 +100,7 @@
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SELECT_FILTER_HEURISTICALLY_SUPPORTED
|
||||
#define PNG_SELECT_FILTER_METHODICALLY_SUPPORTED
|
||||
/*#undef PNG_SELECT_FILTER_SUPPORTED*/
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SETTING_SUPPORTED
|
||||
@@ -193,6 +192,8 @@
|
||||
/* settings */
|
||||
#define PNG_ABORT { (abort()); }
|
||||
#define PNG_API_RULE 0
|
||||
#define PNG_COMPRESSION_BUFFER_LIMIT 8453377
|
||||
#define PNG_COMPRESSION_BUFFER_MAX 8453377
|
||||
#define PNG_DEFAULT_GAMMA_ACCURACY 665
|
||||
#define PNG_DEFAULT_READ_MACROS 1
|
||||
#define PNG_GAMMA_THRESHOLD_FIXED 153
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
;Version 1.7.0beta79
|
||||
;Version 1.7.0beta80
|
||||
;--------------------------------------------------------------
|
||||
; LIBPNG symbol list as a Win32 DEF file
|
||||
; Contains all the symbols that can be exported from libpng
|
||||
|
||||
Reference in New Issue
Block a user