• 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
Re: Attempting to draw upon a CGLayer upon a NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Attempting to draw upon a CGLayer upon a NSView
      • From: Scott Thompson <email@hidden>
  • Prev by Date: NSTextFieldCell and vertical alignment
  • Next by Date: Re: NSTextFieldCell and vertical alignment
  • Previous by thread: Re: Attempting to draw upon a CGLayer upon a NSView
  • Next by thread: Re: Attempting to draw upon a CGLayer upon a NSView
  • Index(es):
    • Date
    • Thread