• 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: Code and Decode a CGContextRef
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code and Decode a CGContextRef


  • Subject: Re: Code and Decode a CGContextRef
  • From: Alastair Houghton <email@hidden>
  • Date: Wed, 28 Nov 2007 10:43:29 +0000

On 28 Nov 2007, at 05:57, Jason Barker wrote:

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?

The CGContextRef isn't a container for bitmap data, it's just a reference; a handle, if you will (if you're a Windows programmer, it's similar to an HDC; if you're an X11 programmer, it's like a GC). As such, encoding or decoding it doesn't make any sense (in the same way that you wouldn't encode or decode a file handle or a socket or anything like that).


However, if the context in question is one of the types that holds data of some sort (e.g. a bitmap context holds image data; a PDF context holds PDF data) then you could save the data, then in your decode routine create a new context with similar properties and load the data into it.

My guess is that you *probably* want to use CGBitmapContextCreateImage() to get a CGImageRef, then CGImageDestinationCreateWithData() or CGImageDestinationCreateWithURL() to turn it into a bitmap file of some sort. I wouldn't go trying to store the data manually (e.g. via CGBitmapContextGetData()) since there are a large number of possible bitmap formats and supporting all of them in your own code would be tedious, not to mention hard to test.

Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________

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


  • Follow-Ups:
    • Re: Code and Decode a CGContextRef
      • From: "Jason Barker" <email@hidden>
References: 
 >Code and Decode a CGContextRef (From: "Jason Barker" <email@hidden>)
 >Re: Code and Decode a CGContextRef (From: David Duncan <email@hidden>)
 >Re: Code and Decode a CGContextRef (From: "Jason Barker" <email@hidden>)

  • Prev by Date: Re: CALayer - delegate not being called?
  • Next by Date: Re: CALayer - delegate not being called?
  • Previous by thread: Re: Code and Decode a CGContextRef
  • Next by thread: Re: Code and Decode a CGContextRef
  • Index(es):
    • Date
    • Thread