Right now, CoreGraphics uses an 8bpp alpha-only image format when a caller requests a shared 8bpp gray buffer.
While this works for many applications, it isn't correct as it discards luminance data in favor of alpha.
By example, if a consumer draws a uniform black region at 100% alpha (0, 0, 0, 255), we will take the 255 from the alpha channel as the gray value, and 255 is perfectly white.
A uniformly dark yellow (128, 128, 0) region rendered at 25% alpha (128, 128, 0, 64 or, premultiplied, 32, 32, 0, 64) will be 25% gray (64, from the alpha channel) when it should be closer to black at 11% gray (30, from a naïve luminance calculation .2126 * Rpremul + .7152 * Gpremul assuming a 1.0 gamma).
Right now, CoreGraphics uses an 8bpp alpha-only image format when a caller requests a shared 8bpp gray buffer.
While this works for many applications, it isn't correct as it discards luminance data in favor of alpha.
By example, if a consumer draws a uniform black region at 100% alpha (
0, 0, 0, 255), we will take the255from the alpha channel as the gray value, and255is perfectly white.A uniformly dark yellow (
128, 128, 0) region rendered at 25% alpha (128, 128, 0, 64or, premultiplied,32, 32, 0, 64) will be 25% gray (64, from the alpha channel) when it should be closer to black at 11% gray (30, from a naïve luminance calculation.2126 * Rpremul + .7152 * Gpremulassuming a 1.0 gamma).