Skip navigation.
 
mlRe: CILinearGradient not linear?
FROM : George Orthwein
DATE : Mon Jun 26 21:34:23 2006

I wanted to follow up this thread with the solution, even though I 
also posted to quartz-dev.

CIContext does indeed default to a colorspace with a linear gamma 
(1.0). The remedy is to create a context with a "normal" gamma using 
kCGColorSpaceGenericRGB:

CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName
(kCGColorSpaceGenericRGB);    
NSDictionary *contextOptions = [NSDictionary 
dictionaryWithObjectsAndKeys:(id)colorSpace, 
kCIContextWorkingColorSpace, (id)colorSpace, 
kCIContextOutputColorSpace,nil];
myCIContext = [CIContext contextWithCGContext:[[NSGraphicsContext 
currentContext] graphicsPort] options:contextOptions];

I've created a test app showing the differences:
http://home.comcast.net/~george.o/CITooLinearGradient.html

I plan to file a doc enhancement request as I don't believe it 
behaves as expected. In fact, I bet most people are unknowingly using 
it as is, effectively creating non-linear gradients, even though 
technically they are linear for a specific colorspace.

(Also, as far as I can tell, this issue only affects the gradient 
filters.)

Hope this helps someone!

George

Related mailsAuthorDate
mlCILinearGradient not linear? George Orthwein May 29, 20:13
mlRe: CILinearGradient not linear? Christian Walther May 30, 10:29
mlRe: CILinearGradient not linear? George Orthwein Jun 26, 21:34