ImageIO.CGImageDestination Class
Use this class to save images and have detailed control over how the images are saved.

See Also: CGImageDestination Members

Syntax

public class CGImageDestination : ObjCRuntime.INativeObject, IDisposable

Remarks

You create new instances of ImageIO.CGImageDestination by calling one of the factory methods.   There are three versions of it:

In the classic API, those methods were called FromUrl, FromData and Create respectively.   But this naming was incorrect, as it did not really create an image destination from a url, or a data.  In the Unified API, they have all been turned into CGImageDestination.Create methods.

Once you have created the image, you can call CGImageDestination.AddImage or CGImageDestination.AddImageAndMetadata to add one or more images.   

To write out the image, you must call the CGImageDestination.Close method.   

c# Example

// The following example shows how to store an image into
// an in-memory PNG file stored inside an NSData.

NSData ImageToPng (CGImage image)
{
   var storage = new NSMutableData ()
   var dest = CGImageDestination.Create (storage, MobileCoreServices.UTType.PNG, imageCount: 1);
   dest.AddImage (image);
   dest.Close (); 
   return storage;
}

Requirements

Namespace: ImageIO
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0