-
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 5 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); | ||
|
||
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,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 (dest.GetHandle (), auxiliaryImageDataType.GetConstant ().GetHandle (), dict.GetHandle ()); | ||
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 Arguments that shouldn't be null should be validated (null-checked) and ArgumentNullException should be thrown. 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. GetHandle is an extension method, so it won't crash when dict is null. For a null value, dict.GetHandle () should return IntPtr.Zero |
||
} | ||
} | ||
} | ||
} | ||
} |
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.GetHandle (), index, auxiliaryImageDataType.GetConstant ().GetHandle ()); | ||
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. Arguments that shouldn't be null should be validated (null-checked) and ArgumentNullException should be thrown. 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 as above |
||
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> (new NSString (CGImageAuxiliaryDataInfo.Data), out data); | ||
|
||
if (success) | ||
info.DepthData = data; | ||
|
||
NSDictionary dict; | ||
success = dictionary.TryGetValue<NSDictionary> (new NSString (CGImageAuxiliaryDataInfo.DataDescription), out dict); | ||
|
||
if (success) | ||
info.DepthDataDescription = dict; | ||
|
||
CGImageMetadata metadata; | ||
success = dictionary.TryGetValue<CGImageMetadata> (new NSString (CGImageAuxiliaryDataInfo.kMetadata), out metadata); | ||
|
||
if (success) | ||
info.Metadata = metadata; | ||
} | ||
|
||
return info; | ||
|
||
} | ||
} | ||
} |
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.