public void SaveImage(Texture2D image, string name, ImageFormat format = ImageFormat.JPG, Action <string> callback = null) { callback = callback == null ? null : RuntimeHelper.ToMainThread(callback); if (image == null) { if (callback != null) { callback("Can't save a null image."); } return; } byte[] rawImage = TextureUtilities.EncodeAsByteArray(image, format); NSData data = NSData.DataWithBytesNoCopy(rawImage, (uint)rawImage.Length); UIImage uiImage = UIImage.ImageWithData(data); UIFunctions.UIImageWriteToSavedPhotosAlbum(uiImage, (savedImage, nsError) => { if (callback != null) { callback(nsError != null ? nsError.LocalizedDescription : null); } }); }
public static CNMutableContact ToCNMutableContact(this Contact contact) { if (contact == null) { return(null); } CNMutableContact nativeContact = new CNMutableContact(); if (contact.FirstName != null) { nativeContact.GivenName = NSString.StringWithUTF8String(contact.FirstName); } if (contact.MiddleName != null) { nativeContact.MiddleName = NSString.StringWithUTF8String(contact.MiddleName); } if (contact.LastName != null) { nativeContact.FamilyName = NSString.StringWithUTF8String(contact.LastName); } if (contact.Company != null) { nativeContact.OrganizationName = NSString.StringWithUTF8String(contact.Company); } if (contact.Birthday != null) { nativeContact.Birthday = contact.Birthday.Value.ToNSDateComponents(); } nativeContact.EmailAddresses = ToCNCotactEmails(contact.Emails); nativeContact.PhoneNumbers = ToCNContactPhoneNumbers(contact.PhoneNumbers); if (contact.Photo != null) { byte[] rawData = TextureUtilities.EncodeAsByteArray(contact.Photo, ImageFormat.PNG); nativeContact.ImageData = NSData.DataWithBytes(rawData, (uint)rawData.Length); } return(nativeContact); }