public static byte [] ConvertFromNative(CGImage src, int newWidth, int newHeight) { try { using (var pool = new Foundation.NSAutoreleasePool()) { var buffer = new byte [newWidth * newHeight * 4]; unsafe { fixed(byte *data = &buffer[0]) { using (var colorSpace = CGColorSpace.CreateDeviceRGB()) { using (var context = new CGBitmapContext((IntPtr)data, newWidth, newHeight, 8, newWidth * 4, colorSpace, CGImageAlphaInfo.PremultipliedLast)) { // draw the image to the bitmap context // this fills the data variable with the image data context.InterpolationQuality = CGInterpolationQuality.High; context.DrawImage(new CGRect(0, 0, newWidth, newHeight), src); } } } } return(buffer); } } catch (Exception e) { throw new Exception("Convert from Native Exception", e); } }
public TValue[] ObjectsForKeys(TKey[] keys, TValue marker) { if (keys == null) { throw new ArgumentNullException(nameof(keys)); } if (marker == null) { throw new ArgumentNullException(nameof(marker)); } if (keys.Length == 0) { return new TValue [] {} } ; using (var pool = new NSAutoreleasePool()) return(NSArray.ArrayFromHandle <TValue> (_ObjectsForKeys(NSArray.From <TKey> (keys).Handle, marker.Handle))); }