Re: Code and Decode a CGContextRef
Re: Code and Decode a CGContextRef
- Subject: Re: Code and Decode a CGContextRef
- From: "Jason Barker" <email@hidden>
- Date: Tue, 27 Nov 2007 22:57:21 -0700
Uh, could both of you type slower so that I can understand you? :)
The image data in the CGContextRef is bitmap data. If I save out the
properties of the context individually, how should I handle the data?
Can that be converted to an NSData object?
Thanks,
Jason
>
> > I have an object with a member variable that is a CGContextRef. I'm
> > trying to implement the NSCoding protocol in my object. What is the
> > best/easiest way to code and decode this CGContextRef?
>
>
> Don't. CGContextRefs (like NSGraphicsContextes) are, under the scenes,
> references to IPC communication channels with the graphics
> infrastructure (I believe). What I know for sure is that they have no
> support for coding.
>
> Recreate a new CGContextRef in initWithCoder: from scratch using the
> appropriate CGContext... function. If you need the contents of the
> context, save them as image data (there should be CGImage... functions
> equivalent to NSImage's -TIFFRepresentation, which returns NSData
> objects which are encodable).
>
> - ∞
>
>
> There isn't one easy way to do it, it depends on how you obtained the
> context in the first place. A bitmap context you would probably encode
> by describing its properties and maybe saving an image from its
> current contents. A PDF context may be described by the PDF data
> itself or a location where the PDF should be saved to. Other kinds of
> contexts are probably best not archived at all.
>
> What kind of context are you working with and where does it come from?
> Answering that question will probably tell you what you want to know
> to encode it well.
> --
> David Duncan
_______________________________________________
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