diff --git a/ANNOUNCE b/ANNOUNCE index 57e95d947..ec073857d 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.6.2beta02 - April 17, 2013 +Libpng 1.6.2beta02 - April 18, 2013 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. @@ -38,12 +38,11 @@ Version 1.6.2beta01 [April 14, 2013] (Flavio Medeiros). Corrected length written to uncompressed iTXt chunks (Samuli Suominen). -Version 1.6.2beta02 [April 17, 2013] +Version 1.6.2beta02 [April 18, 2013] Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length written by libpng-1.6.0 and 1.6.1. Levchenko). - Added #ifdef PNG_WRITE_sRGB_SUPPORTED, etc., tests where needed in - png_image_write_main() in pngwrite.c (bug report from Yuriy Levchenko). + Disallow storing sRGB information when the sRGB is not supported. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 65c03bd0b..112311c51 100644 --- a/CHANGES +++ b/CHANGES @@ -4486,11 +4486,10 @@ Version 1.6.2beta01 [April 14, 2013] (Flavio Medeiros). Corrected length written to uncompressed iTXt chunks (Samuli Suominen). -Version 1.6.2beta02 [April 17, 2013] +Version 1.6.2beta02 [April 18, 2013] Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length written by libpng-1.6.0 and 1.6.1. - Added #ifdef PNG_WRITE_sRGB_SUPPORTED, etc., tests where needed in - png_image_write_main() in pngwrite.c (bug report from Yuriy Levchenko). + Disallow storing sRGB information when the sRGB is not supported. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/contrib/libtests/pngunknown.c b/contrib/libtests/pngunknown.c index 9b8de34b4..25452dbc9 100644 --- a/contrib/libtests/pngunknown.c +++ b/contrib/libtests/pngunknown.c @@ -139,23 +139,128 @@ static struct { "PLTE", PNG_INFO_PLTE, png_PLTE, 0, 0, ABSENT, 0 }, /* Non-critical chunks that libpng handles */ - { "bKGD", PNG_INFO_bKGD, png_bKGD, 0, 1, START, 0 }, - { "cHRM", PNG_INFO_cHRM, png_cHRM, 0, 1, START, 0 }, - { "gAMA", PNG_INFO_gAMA, png_gAMA, 0, 1, START, 0 }, - { "hIST", PNG_INFO_hIST, png_hIST, 0, 1, ABSENT, 0 }, - { "iCCP", PNG_INFO_iCCP, png_iCCP, 0, 1, ABSENT, 0 }, - { "iTXt", PNG_INFO_iTXt, png_iTXt, 0, 1, ABSENT, 0 }, - { "oFFs", PNG_INFO_oFFs, png_oFFs, 0, 1, START, 0 }, - { "pCAL", PNG_INFO_pCAL, png_pCAL, 0, 1, START, 0 }, - { "pHYs", PNG_INFO_pHYs, png_pHYs, 0, 1, START, 0 }, - { "sBIT", PNG_INFO_sBIT, png_sBIT, 0, 1, START, 0 }, - { "sCAL", PNG_INFO_sCAL, png_sCAL, 0, 1, START, 0 }, - { "sPLT", PNG_INFO_sPLT, png_sPLT, 0, 1, ABSENT, 0 }, - { "sRGB", PNG_INFO_sRGB, png_sRGB, 0, 1, START, 0 }, - { "tEXt", PNG_INFO_tEXt, png_tEXt, 0, 1, START, 0 }, - { "tIME", PNG_INFO_tIME, png_tIME, 0, 1, START, 0 }, - { "tRNS", PNG_INFO_tRNS, png_tRNS, 0, 0, ABSENT, 0 }, - { "zTXt", PNG_INFO_zTXt, png_zTXt, 0, 1, END, 0 }, + /* This is a mess but it seems to be the only way to do it - there is no way to + * check for definition outside a #if. + */ + { "bKGD", PNG_INFO_bKGD, png_bKGD, +# ifdef PNG_READ_bKGD_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "cHRM", PNG_INFO_cHRM, png_cHRM, +# ifdef PNG_READ_cHRM_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "gAMA", PNG_INFO_gAMA, png_gAMA, +# ifdef PNG_READ_gAMA_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "hIST", PNG_INFO_hIST, png_hIST, +# ifdef PNG_READ_hIST_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "iCCP", PNG_INFO_iCCP, png_iCCP, +# ifdef PNG_READ_iCCP_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "iTXt", PNG_INFO_iTXt, png_iTXt, +# ifdef PNG_READ_iTXt_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "oFFs", PNG_INFO_oFFs, png_oFFs, +# ifdef PNG_READ_oFFs_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "pCAL", PNG_INFO_pCAL, png_pCAL, +# ifdef PNG_READ_pCAL_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "pHYs", PNG_INFO_pHYs, png_pHYs, +# ifdef PNG_READ_pHYs_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "sBIT", PNG_INFO_sBIT, png_sBIT, +# ifdef PNG_READ_sBIT_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "sCAL", PNG_INFO_sCAL, png_sCAL, +# ifdef PNG_READ_sCAL_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "sPLT", PNG_INFO_sPLT, png_sPLT, +# ifdef PNG_READ_sPLT_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "sRGB", PNG_INFO_sRGB, png_sRGB, +# ifdef PNG_READ_sRGB_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "tEXt", PNG_INFO_tEXt, png_tEXt, +# ifdef PNG_READ_tEXt_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "tIME", PNG_INFO_tIME, png_tIME, +# ifdef PNG_READ_tIME_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "tRNS", PNG_INFO_tRNS, png_tRNS, +# ifdef PNG_READ_tRNS_SUPPORTED + 0, +# else + 1, +# endif + 0, ABSENT, 0 }, + { "zTXt", PNG_INFO_zTXt, png_zTXt, +# ifdef PNG_READ_zTXt_SUPPORTED + 0, +# else + 1, +# endif + 1, END, 0 }, /* No libpng handling */ { "sTER", PNG_INFO_sTER, png_sTER, 1, 1, START, 0 }, @@ -955,6 +1060,7 @@ main(void) { fprintf(stderr, " test ignored because libpng was not built with unknown chunk support\n"); - return 0; + /* So the test is skipped: */ + return 77; } #endif diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index 70a90bdf2..fbd6778cf 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -10139,6 +10139,7 @@ int main(int argc, char **argv) int main(void) { fprintf(stderr, "pngvalid: no write support in libpng, all tests skipped\n"); - return 0; + /* So the test is skipped: */ + return 77; } #endif diff --git a/png.c b/png.c index a894ac50d..330fc2b34 100644 --- a/png.c +++ b/png.c @@ -768,13 +768,13 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.6.2beta02 - April 14, 2013" PNG_STRING_NEWLINE \ + "libpng version 1.6.2beta02 - April 18, 2013" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2013 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.6.2beta02 - April 14, 2013\ + return "libpng version 1.6.2beta02 - April 18, 2013\ Copyright (c) 1998-2013 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; @@ -2275,7 +2275,10 @@ png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace, png_icc_check_tag_table(png_ptr, colorspace, name, profile_length, profile)) { - png_icc_set_sRGB(png_ptr, colorspace, profile, 0); +# ifdef PNG_sRGB_SUPPORTED + /* If no sRGB support, don't try storing sRGB information */ + png_icc_set_sRGB(png_ptr, colorspace, profile, 0); +# endif return 1; } diff --git a/pngrtran.c b/pngrtran.c index 4485e40aa..17bbb9d35 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -223,6 +223,8 @@ translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, */ # ifdef PNG_READ_sRGB_SUPPORTED png_ptr->flags |= PNG_FLAG_ASSUME_sRGB; +# else + PNG_UNUSED(png_ptr) # endif if (is_screen) output_gamma = PNG_GAMMA_sRGB; diff --git a/pngtest.c b/pngtest.c index 03fb15b72..a74e0e876 100644 --- a/pngtest.c +++ b/pngtest.c @@ -43,7 +43,23 @@ #include "png.h" -#ifdef PNG_READ_SUPPORTED /* else nothing can be done */ +/* Known chunks that exist in pngtest.png must be supported or pngtest will fail + * simply as a result of re-ordering them. This may be fixed in 1.7 + */ +#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\ + defined PNG_READ_bKGD_SUPPORTED &&\ + defined PNG_READ_cHRM_SUPPORTED &&\ + defined PNG_READ_gAMA_SUPPORTED &&\ + defined PNG_READ_oFFs_SUPPORTED &&\ + defined PNG_READ_pCAL_SUPPORTED &&\ + defined PNG_READ_pHYs_SUPPORTED &&\ + defined PNG_READ_sBIT_SUPPORTED &&\ + defined PNG_READ_sCAL_SUPPORTED &&\ + defined PNG_READ_sRGB_SUPPORTED &&\ + defined PNG_READ_tEXt_SUPPORTED &&\ + defined PNG_READ_tIME_SUPPORTED &&\ + defined PNG_READ_zTXt_SUPPORTED + #include "zlib.h" /* Copied from pngpriv.h but only used in error messages below. */ #ifndef PNG_ZBUF_SIZE @@ -1945,7 +1961,8 @@ main(void) { fprintf(STDERR, " test ignored because libpng was not built with read support\n"); - return 0; + /* And skip this test */ + return 77; } #endif diff --git a/pngwrite.c b/pngwrite.c index 196e8c0f7..c8b717a79 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.6.1 [March 28, 2013] + * Last changed in libpng 1.6.2 [(PENDING RELEASE)] * Copyright (c) 1998-2013 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.) @@ -2074,12 +2074,9 @@ png_image_write_main(png_voidp argument) if (write_16bit) { -#ifdef PNG_WRITE_gAMA_SUPPORTED /* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */ png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR); -#endif -#ifdef PNG_WRITE_cHRM_SUPPORTED if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB)) png_set_cHRM_fixed(png_ptr, info_ptr, /* color x y */ @@ -2089,20 +2086,15 @@ png_image_write_main(png_voidp argument) /* blue */ 15000, 6000 ); } -#endif -#ifdef PNG_WRITE_sRGB_SUPPORTED else if (!(image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB)) png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL); -#endif -#ifdef PNG_WRITE_gAMA_SUPPORTED /* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit * space must still be gamma encoded. */ else png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE); -#endif /* Write the file header. */ png_write_info(png_ptr, info_ptr);