diff --git a/src/ImageIO/CGImageDestination.cs b/src/ImageIO/CGImageDestination.cs index ee76b3c0bc4c..39a1edb738df 100644 --- a/src/ImageIO/CGImageDestination.cs +++ b/src/ImageIO/CGImageDestination.cs @@ -188,6 +188,31 @@ internal NSMutableDictionary ToDictionary () } #endif + [Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)] + public partial class CGImageAuxiliaryDataInfo { + public NSData DepthData { get; set; } + + public NSDictionary DepthDataDescription { get; set; } + + public CGImageMetadata Metadata { get; set; } + + internal NSMutableDictionary ToDictionary () + { + var dict = new NSMutableDictionary (); + + if (Metadata != null) + dict.LowlevelSetObject (Metadata.Handle, kMetadata); + + if (DepthDataDescription != null) + dict.LowlevelSetObject (DepthDataDescription.Handle, DataDescription); + + if (DepthData != null) + dict.LowlevelSetObject (DepthDataDescription.Handle, Data); + + return dict; + } + } + public class CGImageDestination : INativeObject, IDisposable { internal IntPtr handle; @@ -470,5 +495,17 @@ public bool CopyImageSource (CGImageSource image, CGImageDestinationOptions opti o.Dispose (); } } + + [Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)] + [DllImport (Constants.ImageIOLibrary)] + static extern void CGImageDestinationAddAuxiliaryDataInfo (IntPtr /* CGImageDestinationRef* */ idst, IntPtr /* CFStringRef* */ auxiliaryImageDataType, IntPtr /* CFDictionaryRef* */ auxiliaryDataInfoDictionary); + + [Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)] + public void AddAuxiliaryDataInfo (CGImageDestination dest, CGImageAuxiliaryDataType auxiliaryImageDataType, CGImageAuxiliaryDataInfo auxiliaryDataInfo) + { + using (var dict = auxiliaryDataInfo?.ToDictionary ()) { + CGImageDestinationAddAuxiliaryDataInfo (dest.GetHandle (), auxiliaryImageDataType.GetConstant ().GetHandle (), dict.GetHandle ()); + } + } } -} +} \ No newline at end of file diff --git a/src/ImageIO/CGImageSource.cs b/src/ImageIO/CGImageSource.cs index d782b38dc83d..290cc5e0285c 100644 --- a/src/ImageIO/CGImageSource.cs +++ b/src/ImageIO/CGImageSource.cs @@ -376,5 +376,44 @@ public CGImageSourceStatus GetStatus (int index) { return CGImageSourceGetStatusAtIndex (handle, index); } + + [Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)] + [DllImport (Constants.ImageIOLibrary)] + static extern IntPtr /* CFDictionaryRef* */ CGImageSourceCopyAuxiliaryDataInfoAtIndex (IntPtr /* CGImageSourceRef* */ isrc, nuint index, IntPtr /* CFStringRef* */ auxiliaryImageDataType); + + [Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)] + public CGImageAuxiliaryDataInfo CopyAuxiliaryDataInfo (CGImageSource imageSource, nuint index, CGImageAuxiliaryDataType auxiliaryImageDataType) + { + var ptr = CGImageSourceCopyAuxiliaryDataInfoAtIndex (imageSource.GetHandle (), index, auxiliaryImageDataType.GetConstant ().GetHandle ()); + if (ptr == IntPtr.Zero) + return null; + + var info = new CGImageAuxiliaryDataInfo (); + + using (var dictionary = Runtime.GetNSObject (ptr)) { + bool success; + + NSData data; + success = dictionary.TryGetValue (new NSString (CGImageAuxiliaryDataInfo.Data), out data); + + if (success) + info.DepthData = data; + + NSDictionary dict; + success = dictionary.TryGetValue (new NSString (CGImageAuxiliaryDataInfo.DataDescription), out dict); + + if (success) + info.DepthDataDescription = dict; + + CGImageMetadata metadata; + success = dictionary.TryGetValue (new NSString (CGImageAuxiliaryDataInfo.kMetadata), out metadata); + + if (success) + info.Metadata = metadata; + } + + return info; + + } } } diff --git a/src/imageio.cs b/src/imageio.cs index 6f4ee0134ede..5b0ffb2be6ed 100644 --- a/src/imageio.cs +++ b/src/imageio.cs @@ -857,6 +857,50 @@ interface CGImageProperties { [Field ("kCGImagePropertyMakerAppleDictionary")] NSString MakerAppleDictionary { get; } #endif + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyImageCount")] + NSString ImageCount { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyWidth")] + NSString Width { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyHeight")] + NSString Height { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyBytesPerRow")] + NSString BytesPerRow { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyNamedColorSpace")] + NSString NamedColorSpace { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyPixelFormat")] + NSString PixelFormat { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyImages")] + NSString Images { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyThumbnailImages")] + NSString ThumbnailImages { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyAuxiliaryData")] + NSString AuxiliaryData { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyAuxiliaryDataType")] + NSString AuxiliaryDataType { get; } + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + [Field ("kCGImagePropertyFileContentsDictionary")] + NSString FileContentsDictionary { get; } } [Since (7,0), MountainLion] @@ -1169,4 +1213,26 @@ interface CGCopyImageSourceOptions { IntPtr kOrientation { get; } } #endif + + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + enum CGImageAuxiliaryDataType { + [Field ("kCGImageAuxiliaryDataTypeDepth")] + Depth, + + [Field ("kCGImageAuxiliaryDataTypeDisparity")] + Disparity, + } + + [Partial] + [Mac (10, 13), iOS (11,0), TV (11,0), Watch (4,0)] + interface CGImageAuxiliaryDataInfo { + [Internal, Field ("kCGImageAuxiliaryDataInfoData")] + IntPtr Data { get; } + + [Internal, Field ("kCGImageAuxiliaryDataInfoDataDescription")] + IntPtr DataDescription { get; } + + [Internal, Field ("kCGImageAuxiliaryDataInfoMetadata")] + IntPtr kMetadata { get; } + } }