Re: Attempting to draw upon a CGLayer upon a NSView
Re: Attempting to draw upon a CGLayer upon a NSView
- Subject: Re: Attempting to draw upon a CGLayer upon a NSView
- From: Alexander Rauchfuss <email@hidden>
- Date: Fri, 10 Mar 2006 22:52:38 -0800
Ah, got lucky already a thread about CGLayer.
I needed a way to compose CIImages offscreen so I decided to use a
CGLayer.
A cocoadev entry pointed me in the right direction.
http://www.cocoadev.com/index.pl?CGLayerCreateWithContextWarning
Below is my simplified CIImage and CGLayer code.
The lines that concern me are:
// This seems like it should work, but then again I do not have much
experience with Quartz.
CIContext *layerContext = [CIContext contextWithCGContext:
CGLayerGetContext(offscreenLayer) options: nil];
// There are no errors when I try to draw to the layer context,
leading me to believe that the CIContext is not the problem.
// spreadImage is set to nil by imageWithCGLayer:
// I am not quite sure what is wrong with offscreenLayer
spreadImage = [[CIImage imageWithCGLayer: offscreenLayer] retain];
- (void)prepareTwoPageSpread
{
CGRect imageOneRect = CGRectZero;
CIImage *imageOneScaled;
if(imageOne)
{
// scaleSingleImage is a CIFilter wrapper.
imageOneScaled = [self scaleSingleImage: imageOne];
imageOneRect = [imageOneScaled extent];
}
// Creating the CGLayer for offscreen rendering of compositing.
CGContextRef mainGraphicsContext = [[NSGraphicsContext
currentContext] graphicsPort];
CGLayerRef offscreenLayer = CGLayerCreateWithContext
(mainGraphicsContext, imageOneRect.size, nil);
CIContext *layerContext = [CIContext contextWithCGContext:
CGLayerGetContext(offscreenLayer) options: nil];
if(imageOneScaled)
{
[layerContext drawImage: imageOneScaled atPoint: CGPointZero
fromRect: imageOneRect];
}
// Problem seems to occur here, as class method returns nil.
spreadImage = [[CIImage imageWithCGLayer: offscreenLayer] retain];
}
Thanks,
Alex Rauchfuss
_______________________________________________
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