Wrong colors of Images with semitransparency rendered to PDF using CGPDFContext or [NSView dataWithPDFInsideRect:]

Originator:hannes.oud.dev
Number:rdar://46897333 Date Originated:21-Dec-2018 12:16 PM
Status:Closed Resolved:DUPLICATE OF 46671538
Product:macOS + SDK Product Version:Xcode 10.1 (10B61)
Classification:Other Bug Reproducible:Always
 
Summary:
When drawing an image with semitransparent pixels in a PDF context the color blending is wrong/unexpected, leading to too dark or desaturated colors. Opaque and fully transparent pixels are handled correctly.

Steps to Reproduce:
Open attached playground
Run playground.
Scroll to the bottom and compare the images „expectedResult“ to 
„pdfResult1“ or „pdfResult2“

Expected Results:
pdfResult1 and pdfResult2 should look like expectedResult


Actual Results:
The blended colors in second and third column of each grid look too dark and grey

Version:
Xcode 10.1 (10B61)

Notes:
One theory about this is that premultiplied alpha is somehow not respected in the blending process.

Also please play around with the variable backgroundColor in the playground. If you set it to red, the top row of each grid should render completely red, as the grids top row colors are plain red with varying alpha.

I think the same applies to CoreGraphics of iOS 12 SDK.

Comments

Closed as duplicate

DUPLICATE OF 46671538

By hannes.oud.dev at Feb. 13, 2019, 8:12 p.m. (reply...)

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!