diff --git a/rtengine/imageio.cc b/rtengine/imageio.cc index ff9c9b559..2078cc623 100644 --- a/rtengine/imageio.cc +++ b/rtengine/imageio.cc @@ -308,6 +308,11 @@ int ImageIO::loadPNG (Glib::ustring fname) return IMIO_HEADERERROR; } + // silence the warning about "invalid" sRGB profiles -- see #4260 +#if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && defined(PNG_SET_OPTION_SUPPORTED) + png_set_option(png, PNG_SKIP_sRGB_CHECK_PROFILE, PNG_OPTION_ON); +#endif + png_infop info = png_create_info_struct (png); png_infop end_info = png_create_info_struct (png); @@ -356,6 +361,22 @@ int ImageIO::loadPNG (Glib::ustring fname) png_set_strip_alpha(png); } + // reading the embedded ICC profile if any + if (png_get_valid(png, info, PNG_INFO_iCCP)) { + png_charp name; + int compression_type; +#if PNG_LIBPNG_VER_MAJOR > 1 || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR > 4) + png_bytep profdata; +#else + png_charp profdata; +#endif + png_uint_32 proflen; + png_get_iCCP(png, info, &name, &compression_type, &profdata, &proflen); + embProfile = cmsOpenProfileFromMem(profdata, proflen); + loadedProfileData = new char[proflen]; + memcpy(loadedProfileData, profdata, proflen); + } + //setting gamma double gamma;