• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
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


  • Subject: Goofy behavior with CICheckerboardGenerator filter and transparency
  • From: Randall Meadows <email@hidden>
  • Date: Thu, 10 Jul 2008 22:34:53 -0600

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 _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Goofy behavior with CICheckerboardGenerator filter and transparency
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: How do I copy a view?
  • Next by Date: Re: Goofy behavior with CICheckerboardGenerator filter and transparency
  • Previous by thread: Re: How do I copy a view?
  • Next by thread: Re: Goofy behavior with CICheckerboardGenerator filter and transparency
  • Index(es):
    • Date
    • Thread