Düzenle

Aracılığıyla paylaş


CGImageDestination Class

Definition

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

public class CGImageDestination : IDisposable, ObjCRuntime.INativeObject
type CGImageDestination = class
    interface INativeObject
    interface IDisposable
Inheritance
CGImageDestination
Implements

Remarks

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

  • Storing the generated image into a file pointed to by an NSUrl.:
  • Storing the generated image into an NSMutableData:
  • Storing the generated image into a CGDataConsumer:

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 Create(NSMutableData, String, Int32, CGImageDestinationOptions) methods.

Once you have created the image, you can call M:ImageIO.CGImageDestination.AddImage* or AddImageAndMetadata(CGImage, CGImageMetadata, CGImageDestinationOptions) to add one or more images.

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

// 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;
}

Properties

Handle

Handle (pointer) to the unmanaged object representation.

TypeIdentifiers

Methods

AddAuxiliaryDataInfo(CGImageAuxiliaryDataType, CGImageAuxiliaryDataInfo)
AddImage(CGImage, CGImageDestinationOptions)
AddImage(CGImage, NSDictionary)
AddImage(CGImageSource, Int32, CGImageDestinationOptions)
AddImage(CGImageSource, Int32, NSDictionary)
AddImageAndMetadata(CGImage, CGImageMetadata, CGImageDestinationOptions)
AddImageAndMetadata(CGImage, CGImageMetadata, NSDictionary)
Close()

Writes the images to the destination and disposes the object.

CopyImageSource(CGImageSource, CGCopyImageSourceOptions, NSError)
CopyImageSource(CGImageSource, NSDictionary, NSError)
Create(CGDataConsumer, String, Int32, CGImageDestinationOptions)
Create(NSMutableData, String, Int32, CGImageDestinationOptions)
Create(NSUrl, String, Int32)
Dispose()

Releases the resources used by the CGImageDestination object.

Dispose(Boolean)

Releases the resources used by the CGImageDestination object.

Finalize()

Finalizer for the CGImageDestination object

GetTypeID()

Type identifier for the ImageIO.CGImageDestination type.

SetProperties(NSDictionary)

Applies to