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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to