-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ImageIO] Update to Xcode 9 #2353
Changes from 2 commits
51964a4
3b95a18
2bacb0c
257d779
4cc16ec
e8ab921
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.Handle); | ||
|
||
if (DepthDataDescription != null) | ||
dict.LowlevelSetObject (DepthDataDescription.Handle, DataDescription.Handle); | ||
|
||
if (DepthData != null) | ||
dict.LowlevelSetObject (DepthDataDescription.Handle, Data.Handle); | ||
|
||
return dict; | ||
} | ||
} | ||
|
||
public class CGImageDestination : INativeObject, IDisposable { | ||
internal IntPtr handle; | ||
|
||
|
@@ -470,5 +495,16 @@ 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); | ||
|
||
public void AddAuxiliaryDataInfo (CGImageDestination dest, CGImageAuxiliaryDataType auxiliaryImageDataType, CGImageAuxiliaryDataInfo auxiliaryDataInfo) | ||
{ | ||
using (var dict = auxiliaryDataInfo?.ToDictionary ()) { | ||
CGImageDestinationAddAuxiliaryDataInfo (NativeObjectHelper.GetHandle (dest), auxiliaryImageDataType.GetConstant ().Handle, dict == null ? IntPtr.Zero : dict.Handle); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
it's shorter and also cover the case where a constant might be |
||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -376,5 +376,43 @@ public CGImageSourceStatus GetStatus (int index) | |
{ | ||
return CGImageSourceGetStatusAtIndex (handle, index); | ||
} | ||
|
||
[iOS(11,0)][Mac (10,13)][Watch(4,0)][TV(11,0)] | ||
[DllImport (Constants.ImageIOLibrary)] | ||
static extern IntPtr /* CFDictionaryRef* */ CGImageSourceCopyAuxiliaryDataInfoAtIndex (IntPtr /* CGImageSourceRef* */ isrc, nuint index, IntPtr /* CFStringRef* */ auxiliaryImageDataType); | ||
|
||
public CGImageAuxiliaryDataInfo CopyAuxiliaryDataInfo (CGImageSource imageSource, nuint index, CGImageAuxiliaryDataType auxiliaryImageDataType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same (copy availability attributes) |
||
{ | ||
var ptr = CGImageSourceCopyAuxiliaryDataInfoAtIndex (imageSource?.Handle ?? IntPtr.Zero, index, auxiliaryImageDataType.GetConstant ().Handle); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if (ptr == IntPtr.Zero) | ||
return null; | ||
|
||
var info = new CGImageAuxiliaryDataInfo (); | ||
|
||
using (var dictionary = Runtime.GetNSObject<NSDictionary> (ptr)) { | ||
bool success; | ||
|
||
NSData data; | ||
success = dictionary.TryGetValue<NSData> (CGImageAuxiliaryDataInfo.Data, out data); | ||
|
||
if (success) | ||
info.DepthData = data; | ||
|
||
NSDictionary dict; | ||
success = dictionary.TryGetValue<NSDictionary> (CGImageAuxiliaryDataInfo.DataDescription, out dict); | ||
|
||
if (success) | ||
info.DepthDataDescription = dict; | ||
|
||
CGImageMetadata metadata; | ||
success = dictionary.TryGetValue<CGImageMetadata> (CGImageAuxiliaryDataInfo.kMetadata, out metadata); | ||
|
||
if (success) | ||
info.Metadata = metadata; | ||
} | ||
|
||
return info; | ||
|
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
[Field ("kCGImageAuxiliaryDataInfoData")] | ||
NSString Data { get; } | ||
|
||
[Field ("kCGImageAuxiliaryDataInfoDataDescription")] | ||
NSString DataDescription { get; } | ||
|
||
[Field ("kCGImageAuxiliaryDataInfoMetadata")] | ||
NSString kMetadata { get; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I named this kMetadata because a Metadata strongly-typed property is already defined for the class in CGImageDestination.cs
I copied how CGImageDestinationOptions was bound for the above. I can change it to work differently if desired. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see
the main difference is that the existing constants are Your new code should use the same pattern, both |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, missed that earlier. Copy
[Watch (4, 0), TV (11, 0), Mac (10, 13), iOS (11, 0)]
to the public method, otherwise the developer won't know if it's available.