[libpng16] Removed non-working ICC profile support code. There was too much

code for too little gain; implementing full ICC color correction is maybe
desireable but is left up to applications.
This commit is contained in:
John Bowler 2012-11-01 08:12:47 -05:00 committed by Glenn Randers-Pehrson
parent 7f912dbeb5
commit 520803d57e
12 changed files with 44 additions and 1382 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.6.0beta31 - October 27, 2012
Libpng 1.6.0beta31 - November 1, 2012
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.
@ -525,7 +525,7 @@ Version 1.6.0beta30 [October 24, 2012]
Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in
pngrtran.c (Domani Hannes).
Version 1.6.0beta31 [October 27, 2012]
Version 1.6.0beta31 [November 1, 2012]
Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30.
Made pngvalid so that it will build outside the libpng source tree.
Changed ICC profile support to allow use of an external color management
@ -550,6 +550,9 @@ Version 1.6.0beta31 [October 27, 2012]
question (typically most users who disable it won't).
Fixed GUIDs in projects/vstudio. Some were duplicated or missing,
resulting in VS2010 having to update the files.
Removed non-working ICC profile support code. There was too much code
for too little gain; implementing full ICC color correction is maybe
desireable but is left up to applications.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -4277,7 +4277,7 @@ Version 1.6.0beta30 [October 24, 2012]
Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in
pngrtran.c (Domani Hannes).
Version 1.6.0beta31 [October 27, 2012]
Version 1.6.0beta31 [November 1, 2012]
Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30.
Made pngvalid so that it will build outside the libpng source tree.
Changed ICC profile support to allow use of an external color management
@ -4302,6 +4302,9 @@ Version 1.6.0beta31 [October 27, 2012]
question (typically most users who disable it won't).
Fixed GUIDs in projects/vstudio. Some were duplicated or missing,
resulting in VS2010 having to update the files.
Removed non-working ICC profile support code. There was too much code
for too little gain; implementing full ICC color correction is maybe
desireable but is left up to applications.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

1158
png.c

File diff suppressed because it is too large Load Diff

96
png.h
View File

@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.6.0beta31 - October 26, 2012
* libpng version 1.6.0beta31 - November 1, 2012
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -11,7 +11,7 @@
* Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.0beta31 - October 26, 2012: Glenn
* libpng versions 0.97, January 1998, through 1.6.0beta31 - November 1, 2012: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -198,7 +198,7 @@
*
* This code is released under the libpng license.
*
* libpng versions 1.2.6, August 15, 2004, through 1.6.0beta31, October 26, 2012, are
* libpng versions 1.2.6, August 15, 2004, through 1.6.0beta31, November 1, 2012, are
* Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors:
@ -310,7 +310,7 @@
* Y2K compliance in libpng:
* =========================
*
* October 26, 2012
* November 1, 2012
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
@ -378,7 +378,7 @@
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.0beta31"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.6.0beta31 - October 26, 2012\n"
" libpng version 1.6.0beta31 - November 1, 2012\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@ -3204,90 +3204,6 @@ PNG_EXPORT(242, void, png_set_check_for_invalid_index,
(png_structrp png_ptr, int allowed));
#endif
/*******************************************************************************
* CMS (Color Management System) SUPPORT
*******************************************************************************
*
* The PNG file format supports embedding of ICC profiles, however libpng
* provides only limited support for handling these profiles. In particular
* libpng includes no support for using the profile to transform data into a
* different color space. If PNG_ICC_SUPPORTED is set, however, libpng allows
* an external CMS to be registered into the png_struct after it is created.
* This simply records a single callback function to transform samples between
* two color spaces.
*/
typedef struct png_cms_data *png_cms_datap, * PNG_RESTRICT png_cms_datarp;
/* An opaque type defined by a specific implementation to hold whatever data
* is required. The implementation is responsible for all storage management
* of this data.
*/
typedef PNG_CALLBACK(png_uint_32, *png_cms_transform_ptr,
(png_const_structrp png_ptr, png_cms_datarp data_ptr, png_const_voidp input,
png_alloc_size_t input_bytes, png_voidp output,
png_alloc_size_t output_bytes, int format, int intent));
/* Transform input[input_bytes] of samples to output[output_bytes]. The
* format of the input and output is given by 'format'. The function shall
* transform only so much input as there is space for in the output buffer.
* 'intent' is the ICC intent required for the transformation.
*
* The connection space data (which may be either the input or output) is
* always either 16-bit achromatic data (as described in Annex F.2 of the v4
* ICC specification) for grayscale PNG files or 16-bit PCSXYZ data for RGB
* PNG files. Any alpha channel may be present in the connection space, in
* which case it is a 16-bit channel and the alpha value follows each sample.
* Samples are not pre-multiplied by the alpha. The connection space data
* is stored as an array of png_uint_16 values in the native representation
* of the machine.
*
* For transforms to the connection space the input is in the PNG format
* using either 8-bit or big-endian 16-bit components. 16-bit quantities use
* the PNG layout - big-endian in two bytes.
*
* By default a transform from the connection space will be to 8-bit sRGB
* (with an optional alpha value) or 8-bit gray encoded with the inverse of
* the sRGB transfer function. If png_set_cms_output is called, however, the
* transform may produce arbitrary output in a format potentially not handled
* by libpng.
*
* It is valid to register a CMS when writing a PNG image, however the CMS
* will only be used to generate appropriate values for cHRM and gAMA of the
* profile.
*
* The format parameter is made up of the following flags:
*/
#define PNG_CMS_FORMAT_FLAG_ALPHA 0x01 /* data has alpha channel */
#define PNG_CMS_FORMAT_FLAG_16BIT 0x02 /* 16-bit image components else 8-bit */
#define PNG_CMS_FORMAT_FLAG_PCS 0x04 /* input is PCS data, else image data */
#ifdef PNG_ICC_SUPPORTED
PNG_EXPORT(243, void, png_set_cms, (png_structrp png_ptr,
png_cms_datap cms_data_ptr, png_cms_transform_ptr cms_transform_function));
/* Register the CMS transform function. The given pointer will be passed to
* every call to the function.
*/
#ifdef PNG_READ_SUPPORTED
PNG_EXPORT(244, void, png_set_cms_output, (png_structrp png_ptr,
int bytes_per_pixel, int rendering_intent));
/* Inform libpng that the transform function will write output requiring
* bytes_per_pixel bytes for each sample. The output need not be in any
* particular format, for example the transform could produce a print
* separation. libpng will provide a buffer equal in size to the row width
* of the image times the bytes_per_pixel value (and the application must
* provide this size buffer.)
*
* This also forces the CMS transform to be used even when it is apparently
* not necessary (e.g. for sRGB input data, or for PNG files with no ICC
* profile information and no sRGB data.) The intent overrides the default,
* which is perceptual.
*/
#endif
#endif
/*******************************************************************************
* END OF CMS (Color Management System) SUPPORT
******************************************************************************/
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
* defs
*/
@ -3297,7 +3213,7 @@ PNG_EXPORT(244, void, png_set_cms_output, (png_structrp png_ptr,
* scripts/symbols.def as well.
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
PNG_EXPORT_LAST_ORDINAL(244);
PNG_EXPORT_LAST_ORDINAL(242);
#endif
#ifdef __cplusplus

View File

@ -1467,16 +1467,15 @@ PNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,
png_colorspacerp colorspace, png_const_charp name,
png_uint_32 profile_length,
png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_icc_set_gAMA_and_cHRM,(
#ifdef PNG_sRGB_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(
png_const_structrp png_ptr, png_colorspacerp colorspace,
png_const_charp name, png_const_bytep profile, uLong adler), PNG_EMPTY);
png_const_bytep profile, uLong adler), PNG_EMPTY);
/* 'adler' is the Adler32 checksum of the uncompressed profile data. It may
* be zero to indicate that it is not available. It is used, if provided,
* as a fast check on the profile when checking to see if it is sRGB.
* The routine may not set gAMA or cHRM if there are problems in the profile,
* however none of these problems are fatal (the profile has already been
* checked.)
*/
#endif
#endif /* iCCP */
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED

View File

@ -1276,7 +1276,7 @@ png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
return;
}
png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);
(void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);
png_colorspace_sync(png_ptr, info_ptr);
}
#endif /* PNG_READ_sRGB_SUPPORTED */
@ -1447,13 +1447,12 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, length);
finished = 1;
/* Set the gAMA and cHRM information, this
* checks for a known sRGB profile. The
* result is 0 on error.
*/
png_icc_set_gAMA_and_cHRM(png_ptr,
&png_ptr->colorspace, keyword, profile,
# ifdef PNG_sRGB_SUPPORTED
/* Check for a match against sRGB */
png_icc_set_sRGB(png_ptr,
&png_ptr->colorspace, profile,
png_ptr->zstream.adler);
# endif
/* Steal the profile for info_ptr. */
if (info_ptr != NULL)

View File

@ -578,7 +578,7 @@ png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)
if (png_ptr == NULL || info_ptr == NULL)
return;
png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent);
(void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent);
png_colorspace_sync_info(png_ptr, info_ptr);
}
@ -1549,35 +1549,4 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
png_ptr->num_palette_max = -1;
}
#endif
#ifdef PNG_ICC_SUPPORTED
void PNGAPI
png_set_cms(png_structrp png_ptr, png_cms_datap cms_data_ptr,
png_cms_transform_ptr cms_transform_function)
{
png_ptr->cms_transform_fn = cms_transform_function;
png_ptr->cms_data_ptr = cms_data_ptr;
}
#ifdef PNG_READ_SUPPORTED
void PNGAPI
png_set_cms_output(png_structrp png_ptr, int bytes_per_pixel,
int rendering_intent)
{
if (png_ptr->mode & PNG_IS_READ_STRUCT)
{
png_ptr->cms_bytes_per_pixel = bytes_per_pixel;
png_ptr->cms_intent = rendering_intent;
/* A CMS must be registered before calling this */
if (png_ptr->cms_transform_fn == NULL)
png_app_error(png_ptr, "no CMS registered to transform output");
}
else
png_app_error(png_ptr, "attempt to do CMS tranform on write");
}
#endif /* PNG_READ_SUPPORTED */
#endif /* PNG_ICC_SUPPORTED */
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */

View File

@ -119,7 +119,6 @@ typedef struct png_colorspace
#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_32 icc_info; /* Record of information from the colorspace */
png_uint_16 rendering_intent; /* Rendering intent of a profile */
#endif
@ -129,74 +128,6 @@ typedef struct png_colorspace
typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
/* ICC specific flags for the 'icc_info' field. */
/* The first four bits are for information defined from the profile, the
* remainder of the bits indicate the presence of specific tags. The #define
* names are derived from the tag name in the ICC 2010 (v4) specification.
*/
# define PNG_ICC_PCSXYZ 0x00000001U /* PCSXYS, else PCSLAB */
# define PNG_ICC_RGB 0x00000002U /* 'RGB ', else 'GRAY ' */
/* 0x00000004U reserved */
/* 0x00000008U reserved */
/* A utility to return the number of channels on the A side of the transform
* given an info value (can be optimized).
*/
# define PNG_ICC_CHANNELS(info) ((((info)&PNG_ICC_RGB)?2U:0U)+1U)
/* The profile description and copyright must be present in all valid ICC
* profiles, however libpng does not use them so absence is just reported as
* a warning. The media white point should be present too, but if it isn't
* all we lose is the ability to know if it differs from the adopted white
* (i.e. the information that the device maxima are actually colored;
* a non-white substrate for a printer, or an uncorrected scan for example.)
* The chromaticAdaptationTag tells us that the adopted white of the original
* differs from the PCS adopted white (which is identical to the PCS
* illuminant and should always be D50).
*/
# define PNG_ICC_profileDescriptionTag 0x00000010U /* required */
# define PNG_ICC_copyrightTag 0x00000020U /* required */
# define PNG_ICC_mediaWhitePointTag 0x00000040U /* required */
# define PNG_ICC_chromaticAdaptationTag 0x00000080U /* optional */
/* Tags that are required in all profiles (except DeviceLink): */
# define PNG_ICC_REQUIRED_BASE 0x00000070U
/* Other tags have to appear in specific profiles. In general a profile must
* either contain appropriate TRC and (for RGB profiles) matrix tags *or* it
* must contain AToB0 and BToA0 - the CLUT based transforms to an absolute
* colorimetric PCS. In the TRC case the PCS encoding must be PCSXYZ.
*/
# define PNG_ICC_redMatrixColumnTag 0x00000100U
# define PNG_ICC_greenMatrixColumnTag 0x00000200U
# define PNG_ICC_blueMatrixColumnTag 0x00000400U
/* 0x00000800U reserved */
# define PNG_ICC_redTRCTag 0x00001000U
# define PNG_ICC_greenTRCTag 0x00002000U
# define PNG_ICC_blueTRCTag 0x00004000U
# define PNG_ICC_grayTRCTag 0x00008000U
# define PNG_ICC_REQUIRED_RGB_MATRIXTRC 0x00007700U /* Required for RGB TRC */
# define PNG_ICC_ALL_TRC 0x0000f000U /* Includes all TRCTags */
# define PNG_ICC_REQUIRED_MATRIX 0x00000700U /* All MatrixColumnTags */
# define PNG_ICC_AToB0Tag 0x00010000U
# define PNG_ICC_BToA0Tag 0x00020000U
# define PNG_ICC_AToB1Tag 0x00040000U
# define PNG_ICC_BToA1Tag 0x00080000U
# define PNG_ICC_AToB2Tag 0x00100000U
# define PNG_ICC_BToA2Tag 0x00200000U
# define PNG_ICC_AToB_TAGS 0x00050000U /* Just AToB0 and AToB1 */
# define PNG_ICC_ALL_LUT 0x003f0000U
/* 0x00400000U reserved */
/* 0x00800000U reserved */
/* The ICC profile specification allows for shortcuts in the cHRM calculation
* via the colorant table (clrt) or the chromaticity tag (chrm).
*/
# define PNG_ICC_chromaticityTag 0x01000000U
# define PNG_ICC_colorantTableTag 0x02000000U
# define PNG_ICC_gamutTag 0x04000000U
/* General flags for the 'flags' field */
#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
@ -548,17 +479,5 @@ struct png_struct_def
png_colorspace colorspace;
#endif
#endif
#ifdef PNG_ICC_SUPPORTED
/* Full ICC support requires an external CMS be registered in the png_struct
* after it is created. The registration stores this information.
*/
png_cms_transform_ptr cms_transform_fn;
png_cms_datap cms_data_ptr;
#ifdef PNG_READ_SUPPORTED
int cms_bytes_per_pixel; /* non-standard output size */
int cms_intent; /* for non-standard output */
#endif
#endif /* PNG_ICC_SUPPORTED */
};
#endif /* PNGSTRUCT_H */

View File

@ -151,7 +151,7 @@ logunsupported = 1
# These are currently experimental features; define them if you want (NOTE:
# experimental options must be disabled before they are defined in this file!)
option ICC disabled
# NONE
# Note that PNG_USR_CONFIG only has an effect when building
# pnglibconf.h
@ -318,20 +318,6 @@ setting USER_CHUNK_MALLOC_MAX
option SAFE_LIMITS enables USER_LIMITS disabled
= SAFE_LIMITS SAFE_LIMITS
# ICC profile support; basic ICC profile support is enabled if iCCP chunk read
# or write is enabled. The application must perform all iCCP profile handling
# itself. If full support is enabled with the option below libpng will attempt
# to do more processing using the profile data itself, this includes setting
# appropriate values for cHRM and gAMA chunks if not present in the stream.
#
# ICC profile support is not build in to core libpng because of the size of the
# code required; an external ICC implementation must be passed to libpng to
# enable it.
#
# WARNING: this option is CURRENTLY UNTESTED because a test CMS implementation
# has not yet been written, as a result it is disabled in current beta builds.
option ICC requires iCCP enables SAVE_INT_32
# All of the following options relate to code capabilities for
# processing image data before creating a PNG or after reading one.
# You can remove these capabilities safely and still be PNG

View File

@ -3,7 +3,7 @@
/* pnglibconf.h - library build configuration */
/* Libpng 1.6.0beta31 - October 26, 2012 */
/* Libpng 1.6.0beta31 - November 1, 2012 */
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
@ -63,7 +63,6 @@
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
#define PNG_hIST_SUPPORTED
#define PNG_iCCP_SUPPORTED
/*#undef PNG_ICC_SUPPORTED*/
#define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_INFO_IMAGE_SUPPORTED
#define PNG_IO_STATE_SUPPORTED

View File

@ -247,5 +247,3 @@ EXPORTS
png_image_write_to_stdio @240
png_convert_to_rfc1123_buffer @241
png_set_check_for_invalid_index @242
png_set_cms @243
png_set_cms_output @244

View File

@ -42,7 +42,6 @@
#define PNG_READ_BIG_ENDIAN_SUPPORTED /* should do nothing! */
#define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
#define PNG_ICC_SUPPORTED /* currently disabled */
#undef PNG_H
#include "../png.h"