mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
[libpng16] Added #ifdef PNG_WRITE_sRGB_SUPPORTED, etc., tests where needed in
png_image_write_main() in pngwrite.c (bug report from Yuriy Levchenko).
This commit is contained in:
@@ -2074,9 +2074,12 @@ 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 */
|
||||
@@ -2086,15 +2089,20 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user