• 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
CGShading & Printing conflicts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CGShading & Printing conflicts


  • Subject: CGShading & Printing conflicts
  • From: Simon Bovet <email@hidden>
  • Date: Tue, 2 Sep 2003 12:50:45 +0200

I'm using the CoreGraphics functions to draw a color gradient in a view. It works perfectly well on screen. But it crashes (EXC_BAD_ACCESS in PDFFunctionEmitReference) as soon as the view is printed...

Below, the code of my NSBezierPath category. (CPColorList is just my own "gradient" object).

I first thought that I release some CG objects too soon. I tried to set all CG* variables as static (to avoid all CG*Release), but the problem persisted.

Any help would be greatly appreciated! Thanks!
Simon




@implementation NSBezierPath (ColorListExtensions)

static void sGetShadingComponents(void *info, const float *inData, float *outData)
{
NSColor *color = [(CPColorList *)info colorAtPosition:*inData];
[color getRed:&outData[0] green:&outData[1] blue:&outData[2] alpha:&outData[3]];
}

-(void)fillWithColorList:(CPColorList *)inColorList
{
[NSGraphicsContext saveCurrentGraphicsState];
[self addClip];

CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceUserRGB);
CGPoint start = CGPointMake(0, 0);
CGPoint end = CGPointMake(100, 100);

CGFunctionCallbacks callbacks;
callbacks.version = 0;
callbacks.evaluate = &sGetShadingComponents;
callbacks.releaseInfo = nil;
CGFunctionRef function = CGFunctionCreate(inColorList, 1, nil, 4, nil, &callbacks);

CGShadingRef shading = CGShadingCreateAxial(colorSpace, start, end, function, YES, YES);

CGContextDrawShading((CGContextRef)[[NSGraphicsContext currentContext] graphicsPort], shading);

CGShadingRelease(shading);
CGFunctionRelease(function);
CGColorSpaceRelease(colorSpace);

[NSGraphicsContext restoreCurrentGraphicsState];
}

@end
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: plug-in problem
  • Next by Date: Re: build executable
  • Previous by thread: Re: plug-in problem
  • Next by thread: Cocoa/run sudo
  • Index(es):
    • Date
    • Thread