NSImage displays sRGB colors incorrectly for some PNGs

Originator:marc.schwieterman
Number:rdar://39509682 Date Originated:17-Apr-2018 04:34 PM
Status:Open Resolved:
Product:macOS + SDK Product Version:10.13.4
Classification:UI/Usability Reproducible:Always
 
Summary:
PNG images that contain an sRGB or gAMA chunk are displayed incorrectly by NSImage. The colors look faded, and their RGB values as measured with Digital Color Meter are different than expected. PNGs that do not contain any ancillary chunks display correctly.

These same images look correct in both QuickLook and Preview. The inspector in Preview shows “sRGB IEC61966-2.1” for the PNGs with either an sRGB or gAMA chunk, and it shows “-“ for PNGs with no ancillary chunks. 

Steps to Reproduce:
These steps use Acorn, but you should be able to use any drawing application that supports sRGB and can export PNGs with an embedded color profile.

The attached playground can be used instead of following these steps. Note that the color specified here corresponds to the rightmost square in the playground images.

1. Create a new document
2. Verify that the color profile is sRGB (Image > Color Profile…)
3. Select the Flood Fill Tool (K)
4. Click on the Fill Color circle at the bottom of the palette and set the RGB values to 12, 34, 56 or a hex value of #0C2238
5. Fill the canvas
6. Open the Web Export dialog (File > Export > Web Export)
7. Select PNG and ensure that “Embed profile” is checked
8. Click Save and save the PNG somewhere
9. Open the resulting file in Preview and use Digital Color Meter set to Display in sRGB to verify that the RGB values are equal or reasonably close to 12, 34, 56
10. Use the file to populate an NSImage object in an application


Expected Results:
The image displayed via an NSImage should meter equal or reasonably close to 12, 34, 56

Actual Results:
The image meters equal to or reasonably close to 137, 170, 188

Version:
10.13.4

Notes:
The attached playground illustrates this issue. Additional information, including source documents, images and some analysis can be found at https://github.com/marcisme/sketch-preview/blob/color/test/color/ANALYSIS.md .

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!