Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Goofy behavior with CICheckerboardGenerator filter and transparency
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Goofy behavior with CICheckerboardGenerator filter and transparency



Didn't have much luck with this question over on cocoa-dev, but this seems like a more logical place to ask anyway, so here's hoping!

-----
I have an NSImageView subclass that I'm filling with a checkerboard pattern, using this method:


- (void)drawRect:(NSRect)aRect
{
 NSColor  *nsColor;
 CIColor  *inputColor0, *inputColor1;
 float    alpha;
 NSNumber  *inputWidth;

nsColor = [[[prefsWdw gridColor1] color] colorUsingColorSpaceName:NSDeviceRGBColorSpace];
alpha = [[prefsWdw gridSlider1] floatValue];
inputColor0 = [CIColor colorWithRed:[nsColor redComponent]
green:[nsColor greenComponent]
blue:[nsColor blueComponent]
alpha:alpha];
nsColor = [[[prefsWdw gridColor2] color] colorUsingColorSpaceName:NSDeviceRGBColorSpace];
alpha = [[prefsWdw gridSlider2] floatValue];
inputColor1 = [CIColor colorWithRed:[nsColor redComponent]
green:[nsColor greenComponent]
blue:[nsColor blueComponent]
alpha:alpha];
inputWidth = [NSNumber numberWithFloat:[[prefsWdw gridSlider] floatValue]];


CIFilter *theFilter = [CIFilter filterWithName:@"CICheckerboardGenerator"];
[theFilter setDefaults];
[theFilter setValue:inputColor0 forKey:@"inputColor0"];
[theFilter setValue:inputColor1 forKey:@"inputColor1"];
[theFilter setValue:inputWidth forKey:@"inputWidth"];
CIImage *transparentBG = [theFilter valueForKey:@"outputImage"];


CIContext *context = [[NSGraphicsContext currentContext] CIContext];
[context drawImage:transparentBG
atPoint:CGPointZero
fromRect:CGRectMake(aRect.origin.x, aRect.origin.y, aRect.size.width, aRect.size.height)];
}


When I adjust the alpha value of the color of the checkerboard pattern, I get really weird behavior; it's kind of hard to describe, so I shot a movie of it and posted it at <http://www.not-pc.com/CheckerboardAlpha.mov >. As you can see, the colors don't "scale" appropriately. All the computing is done in this routine, there's no outside stuff being done beyond adjusting the sliders and colors. I also tried NSCalibratedRGBColorSpace, and it behaved the same way.

Any ideas on what is going on?  What I might have done wrong?


Thanks! randy

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.