mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
API reduction, PNG compression level
PNG compression level setting API: this allows the various compression settings
controlling deflate, fitlering, and so on to be set via a single setting with
six values. This is currently documented in png.h ("Write compression
settings").
Internally the compression settings have been tuned both for the overall setting
and for any specific settings made by the original APIs.
APIs to control iCCP chunk compression separately have been added.
contrib/examples/pngcp.c has been modified to accomodate the new compression
setting and to include options for separate control of iCCP chunk compression.
The new ABI, png_setting, has been modified to accomodate a wider range of
settings and most of the old compression control ABIs have been replaced by
function-like macros with the same API which call png_setting. This is an API
check in 1.7.0 for png_setting (alone). png_setting now handles all of
png_set_option. This eliminates 19 ABIs at the cost of adding 1 (png_setting).
CRC and benign error checking has been updated internally to use bit-fields and
the CRC calculation skip when the CRC is not used has been improved slightly to
avoid the initialization of the CRC. A new png_setting based API allows more
detailed control of benign error/warning messages (this may change, the internal
error handling seems too complex.) The ERROR_NUMBERS support has been removed
with the intent of implementing proper i18n.
The memcpy-size-0 issue in png_push_fill_buffer has been fixed, with an
appropriate debug() assert if a fill for 0 bytes occurs.
Most PNG_FLAG_ values for png_struct::flags have been eliminated (as a result of
the benign error handling changes). Only one remains.
Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
40
pngwrite.c
40
pngwrite.c
@@ -538,24 +538,28 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* This is a highly dubious configuration option; by default it is off,
|
||||
* but it may be appropriate for private builds that are testing
|
||||
* extensions not conformant to the current specification, or of
|
||||
* applications that must not fail to write at all costs!
|
||||
*/
|
||||
#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
|
||||
/* In stable builds only warn if an application error can be completely
|
||||
* handled.
|
||||
*/
|
||||
png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
|
||||
#endif
|
||||
|
||||
/* App warnings are warnings in release (or release candidate) builds but
|
||||
* are errors during development.
|
||||
*/
|
||||
#if PNG_RELEASE_BUILD
|
||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||
#endif
|
||||
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
# if !PNG_RELEASE_BUILD
|
||||
/* Always quit on error prior to release */
|
||||
png_ptr->benign_error_action = PNG_ERROR;
|
||||
png_ptr->app_warning_action = PNG_ERROR;
|
||||
png_ptr->app_error_action = PNG_ERROR;
|
||||
# else /* RELEASE_BUILD */
|
||||
/* Allow benign errors on write, subject to app control. */
|
||||
# ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
|
||||
png_ptr->benign_error_action = PNG_WARN;
|
||||
png_ptr->app_error_action = PNG_WARN;
|
||||
png_ptr->app_warning_action = PNG_WARN;
|
||||
# else /* !BENIGN_WRITE_ERRORS */
|
||||
/* libpng build without benign error support; the application
|
||||
* author has to be assumed to be correct, so:
|
||||
*/
|
||||
png_ptr->benign_error_action = PNG_ERROR;
|
||||
png_ptr->app_warning_action = PNG_ERROR;
|
||||
png_ptr->app_error_action = PNG_ERROR;
|
||||
# endif /* !BENIGN_WRITE_ERRORS */
|
||||
# endif /* RELEASE_BUILD */
|
||||
# endif /* BENIGN_ERRORS */
|
||||
}
|
||||
|
||||
return png_ptr;
|
||||
|
||||
Reference in New Issue
Block a user