• 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: NSGraphicsContext restore crashes my xtension
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSGraphicsContext restore crashes my xtension


  • Subject: Re: NSGraphicsContext restore crashes my xtension
  • From: Graham Cox <email@hidden>
  • Date: Mon, 28 Jul 2008 21:53:59 +1000


On 28 Jul 2008, at 6:17 pm, Ken Tozier wrote:

Maybe I'm just misunderstanding what saveGraphicsState does, behind the scenes, but I actually need to draw into the passed in CGPDFContext, not any sort of view/image/winbow context. Best I can figure, this requires a forced context switch, not just saving and restoring the graphics state of whatever context happens to be current.

I couldn't find any way to draw into a CGGraphicsContext with NSxxx drawing commands without first creating a new context from the CGContext and second manually setting this context to be the current one. Is there a better/cleaner way?


OK, so you need to do something like this (typed into mail)

- (void) myDrawStuffInContext:(CGContextRef) aContext
{
    [NSGraphicsContext saveGraphicsState];

NSGraphicsContext* myNSContext = [NSGraphcsContext graphicsContextWithGraphicsPort:aContext flipped:NO]; // make NSGraphicsContext from CGContext
[NSGraphicsContext setCurrentContext:myNSContext]; // switch to this context


    /* do all my drawing */

    [NSGraphicsContext restoreGraphicsState];
}





hth,

Graham
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Re: NSGraphicsContext restore crashes my xtension (From: email@hidden)
 >Re: NSGraphicsContext restore crashes my xtension (From: glenn andreas <email@hidden>)
 >Re: NSGraphicsContext restore crashes my xtension (From: Ken Tozier <email@hidden>)
 >Re: NSGraphicsContext restore crashes my xtension (From: Graham Cox <email@hidden>)
 >Re: NSGraphicsContext restore crashes my xtension (From: "Ken Ferry" <email@hidden>)
 >Re: NSGraphicsContext restore crashes my xtension (From: Ken Tozier <email@hidden>)

  • Prev by Date: How to get the cursor animation effects - Clouds of smoke when deleting something
  • Next by Date: Re: How to get the cursor animation effects - Clouds of smoke when deleting something
  • Previous by thread: Re: NSGraphicsContext restore crashes my xtension
  • Next by thread: observers removed?
  • Index(es):
    • Date
    • Thread