• 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: Jean-Daniel Dupas <email@hidden>
  • Date: Wed, 28 Nov 2007 18:19:03 +0100


Le 28 nov. 07 à 17:57, Jason Barker a écrit :

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


The CFMutableDataRef is the destination buffer where it will store your image data.
NSMutableData *imgData = [NSMutableData data];
CGImageDestinationRef dest = CGImageDestinationCreateWithData (imgData, ...);
CGImageDestinationAddImage(dest, myCGImageRef, NULL);
CGImageDestinationFinalize(dest);
CFRelease(dest);


Now, imgData should contains your image data and you can encode it.

Your image can contains a lots of properties (width, height, resolution, colorspace, etc...) so you don't have to archive additional meta-data.

To restore the context, you probably can use CGImageSource to create a CGImageRef, creating your context as needed, and then draw the image on your new context.


_______________________________________________

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: 
 >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>)
 >Re: Code and Decode a CGContextRef (From: "Jason Barker" <email@hidden>)

  • Prev by Date: Re: Custom-view cursor changing
  • Next by Date: Custom Formatters and NSTableView
  • Previous by thread: Re: Code and Decode a CGContextRef
  • Next by thread: Force redisplay of NSTextField after NSFormatter subclass change
  • Index(es):
    • Date
    • Thread