Core graphics doesn't work with AppKit drawing (on PowerBook)
Core graphics doesn't work with AppKit drawing (on PowerBook)
- Subject: Core graphics doesn't work with AppKit drawing (on PowerBook)
- From: Oleg Kibirev <email@hidden>
- Date: Fri, 15 Sep 2006 13:25:47 -0700
Hi all,
The following paint function produces striped display instead of the
expected lighted blue oval. The bug doesn't happen if I don't set a
clip region (which I need for my purposes). I can also turn anti-
aliasing on, but then my oval gets ugly pixels of random colors on
the sides. NSIntegralRect is no help here, since I am drawing a
curved path. Now I am drawing to an 8x zoomed NSImage with
antialiasing off and then scaling it down to get smooth line and
cancel out colored pixels.
I encountered this problem on the last revision PowerBook G4 with
OSX10.4.7 and ATI Mobility Radeon 9700. It doesn't happen on Intel
iMacs, but obviously I have to make my code work on all platforms.
Has anyone found a simple workaround for this problem? Is there at
least a way to turn off subpixel positioning together with antialiasing?
Big Thanks in advance!
Oleg
-(void)drawRect: (NSRect)r {
r = [self bounds];
[[NSColor clearColor] set];
NSRectFill(r);
//[[NSGraphicsContext currentContext] setShouldAntialias: NO]; // or
this line is uncommented
[[NSBezierPath bezierPathWithOvalInRect:r] addClip]; // Or this line
is commented
// gradient is drawn (but ugly)
[[NSColor blueColor] set];
NSRectFill(r);
CIColor *c1 = [[[CIColor alloc] initWithColor: [NSColor whiteColor]]
autorelease];
CIColor *c2 = [[[CIColor alloc] initWithColor: [NSColor clearColor]]
autorelease];
CIFilter *grad = [CIFilter filterWithName:@"CILinearGradient"];
[grad setValue:c1 forKey:@"inputColor0"];
[grad setValue:c2 forKey:@"inputColor1"];
CIVector *p1 = [CIVector vectorWithX:0 Y:r.size.height];
CIVector *p2 = [CIVector vectorWithX:0 Y:0];
[grad setValue:p1 forKey:@"inputPoint0"];
[grad setValue:p2 forKey:@"inputPoint1"];
CIImage *ci = [grad valueForKey:@"outputImage"];
CIContext *ctx = [[NSGraphicsContext currentContext] CIContext];
[ctx drawImage: ci atPoint: CGPointMake(0,0) fromRect: CGRectMake(0,
0, r.size.width, r.size.height)];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden