8-bit image with CGBitmapContextCreate has artifacts when created from NSImage when created with lockFocus/drawInRect/unlockFocus

Originator:gnachman
Number:rdar://FB9003081 Date Originated:12/12/2021
Status:Open Resolved:
Product:AppKit Product Version:
Classification: Reproducible:
 
If you create an image with:
 [image lockFocus]; [sourceImage drawInRect:…]; [image unlockFocus]
And then you try to draw that image into a CGBitmapContext with 8 bits per component, there are rendering artifacts. It only works with 16 bits per component.

I have attached a sample project that demonstrates the artifacts. Changing bitsPerComponent from 8 to 16 fixes it.

I would expect that I could draw any CGImage into a bitmap context regardless of how it was created.

In the attached screenshot please note the artifacts on the bottom of the gradient and around the dashed line. pic.png shows the source image, which does not have those artifacts.

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!