The filter selection options are made more intuitive (IMO, but I am not an
Intuitive User). Dummy code added for methodical filter selection.
Signed-off-by: John Bowler <jbowler@acm.org>
This implements the heuristic part of filter selction, the methodic testing
approach is still not implemented. png_set_option methods are incomplete.
Signed-off-by: John Bowler <jbowler@acm.org>
This removes the side-effect on the png_struct palette of calling png_set_PLTE
or png_set_tRNS. NOTE: this is a quiet API change, it was possible before to
alter the palette on a PNG image by using png_set_PLTE, but this was unintended
and inconsistent with the other png_set APIs.
Fix a bug in palette index checking; png_struct::num_palette could, in
principle, get changed by the transformations (e.g. png_set_quantize) and this
would invalidate the check. The palette checking init function now makes a copy
of png_struct::num_palette.
Fix a bug in pngvalid error handling. A png_error in png_write_info is not
continuable (a valid image cannot necessarily be written afterward) because the
png_error aborts the write of subsequent pre-IDAT chunks. In particular an
abort as a result of a bogus colorspace information (gAMA, cHRM, sBIT etc)
prevents the write of the PLTE chunk.
Signed-off-by: John Bowler <jbowler@acm.org>
Unify the compression code so that inflate calls are localized to a common
routine. Ground work for filter selection support. Minor API changes to use
void* not byte* for data parameters. Unification of some of the compression
code with the decompression code; IDAT_size replaces IDAT_read_size and
zbuffer_size, IDAT reading and writing is no longer controlled by the size of
the compression buffer.
Signed-off-by: John Bowler <jbowler@acm.org>
Fixes the case where IDAT is treated as unknown and saved; the first IDAT chunk
ends up 'before' IDAT, the rest 'after', pngunknown has to take this into
account since it checks before and after.
This commit moves code round and changes the filter write interfaces that took
png_uint_32 buffer pixel counts to unsigned int. Also moves compression code
and definitions into pngwutil.c so that the compression code is isolated from
other definitions.
Signed-off-by: John Bowler <jbowler@acm.org>
Improve pngvalid coverage of filter combinations, remove the (new in 1.7) code
which disabled previous-row filters on the first row of an image in some cases.
Signed-off-by: John Bowler <jbowler@acm.org>
This tests the 'size' images in the sequential reader, the existing test case
only uses the progressive reader which means that important parts of the filter
code never got tested.
Signed-off-by: John Bowler <jbowler@acm.org>
The code failed to zero out the row buffer at the start of a pass where the AVG
filter is used because 'row_number' is not always zero (on interlaced images)
and, apparently, the assertion that the buffer had been zeroed when allocated
was not always correct for non-interlaced images. Revealed by pngvalid --size
with a hack to make it always use AVG.
Signed-off-by: John Bowler <jbowler@acm.org>
This error prevents the read of non-interlaced PNG files with height 1. A
simple bracket problem caused by hasty multiple edits.
Signed-off-by: John Bowler <jbowler@acm.org>
This fix is to the PNG_MAX_GAMMA_8 handling and png_set_rgb_to_gray, which had
bugs which were likely to expose end cases of rgb-to-gray conversion errors.
This might explain some of the machine math dependencies we are seeing
(*might*).
Signed-off-by: John Bowler <jbowler@acm.org>
This only changes the detection of invalid application behavior (too many calls
to png_read_row) from an affirm to a png_app_error.
Signed-off-by: John Bowler <jbowler@acm.org>