• 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: "Jason Barker" <email@hidden>
  • Date: Wed, 28 Nov 2007 09:57:34 -0700

Actually, I knew that it was a reference and not a "container". I've just
not done much with C-style functions and structs, and so Quartz makes my
head swim a bit, trying to change from Objective-C style syntax to C-style
syntax.

Anyway, I just wasn't sure if I had to code/decode each property from the
CGContextRef (width, height, bitsPerComponent, bytesPerRow, dataSize,
colorspace, data, etc.) or if there was an Objective-C type that could just
do it all for me.

With regards to the function CGImageDestinationCreateWithData(), I think I
understand what to pass in for the last three parameters it takes (namely
'type', 'count' and 'options') but I don't know how to go from a CGImageRef
to a CFMutableDataRef. Is this what I'm supposed to do? And then once I have
a CGImageDestinationRef, how do I code/decode that?

Thanks for your help,
Jason

>

On Nov 28, 2007 3:43 AM, Alastair Houghton <email@hidden>
wrote:

> 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: Jean-Daniel Dupas <email@hidden>
    • Re: Code and Decode a CGContextRef
      • From: Alastair Houghton <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>)
 >Re: Code and Decode a CGContextRef (From: Alastair Houghton <email@hidden>)

  • Prev by Date: Re: Adding HUD context pannel to rows within NSOutlineView
  • Next by Date: Re: Code and Decode a CGContextRef
  • Previous by thread: Re: Code and Decode a CGContextRef
  • Next by thread: Re: Code and Decode a CGContextRef
  • Index(es):
    • Date
    • Thread