private void PictureSelected(NSDictionary pictureDict) { float maxWidth = 100; if ((pictureDict[UIImagePickerController.MediaType] as NSString) == "public.image") { Picture = pictureDict[UIImagePickerController.EditedImage] as UIImage; if (Picture == null) { Picture = pictureDict[UIImagePickerController.OriginalImage] as UIImage; } var size = Picture.Size; // Show the UI, and on a callback, do the scaling, so the user gets an animation NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(0), delegate { if (size.Width > maxWidth || size.Height > maxWidth) { Picture = Scale(Picture, new SizeF(maxWidth, (float)(maxWidth * size.Height / size.Width))); } SeekiosImageView.Image = Picture; App.Locator.AddSeekios.SeekiosImage = ImageHelper.ImageToByte(Picture); if (App.Locator.AddSeekios.IsAdding) { EnableSaveButton(); } else { SaveButton.Enabled = true; } }); } pictureDict.Dispose(); }
private void Save(string path, int size, Action <bool> callback, NSDictionary data) { bool result = false; UIImage photo = null; UIImage source = null; NSData file = null; NSError error = null; try { source = data.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage; if (source != null) { photo = ScaleImage(source, size); file = photo.AsJPEG(); bool saved = file.Save(path, false, out error); if (!saved) { Context.HandleException(new NonFatalException(D.IO_EXCEPTION, error.LocalizedDescription)); } result = saved; } } finally { if (photo != null) { photo.Dispose(); } if (source != null) { source.Dispose(); } if (file != null) { file.Dispose(); } if (error != null) { error.Dispose(); } if (data != null) { data.Dispose(); } } Task.Run(() => { Thread.Sleep(300); Context.InvokeOnMainThread(() => callback(result)); }); }
void IMAMService.UtilMAMService() { try { //IntuneMAMAppConfigManager appConfig = IntuneMAMAppConfigManager.Instance; // IntuneMAMAppConfig conf = IntuneMAMAppConfig.; // NSDictionary paramsGroups1 =IntuneMAMAppConfig_Extensions. IntuneMAMPolicyManager value = IntuneMAMPolicyManager.Instance; Utils.Print($"------ Es ManagementEnabled: {value.IsManagementEnabled.ToString()}"); NSDictionary dictionary = value.DiagnosticInformation; NSString[] keys = { new NSString(Mobile.ID_DIC_INTUNE) }; NSDictionary paramsGroups = dictionary.GetDictionaryOfValuesFromKeys(keys); //NSDictionary paramsGroups = IntuneMAMAppConfigManager.Instance.GetDictionaryOfValuesFromKeys(keys); //IntuneMAMAppConfig_Extensions.GetFullData(AppConfig); NSObject paramsGroup = paramsGroups.ElementAt(0).Value; var data = Mobile.configData; // Convert parameters to string and regenerate the certificate data.ftpDownload_User = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_USER)).ToString(); data.ftpDownload_Pass = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PASS)).ToString(); data.ftpDownload_Host = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_HOST)).ToString(); data.ftpDownload_Port = int.Parse(paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PORT)).ToString()); data.ftpDownload_Path = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PATH)).ToString(); data.HasIntune = true; data.GenerateCert(paramsGroup.ValueForKey(new NSString(Mobile.ID_CERTIFICATE)).ToString()); // Utils.Print("Intune parameters loaded.."); // Utils.Print("FTP: " + data.ftpDownload_Host + ":" + data.ftpDownload_Port + " - " + data.ftpDownload_User + " [ " + data.ftpDownload_Pass + " ]"); // Utils.Print("Certificate: " + data.certificate.FriendlyName + " [ " + data.certificate.NotAfter + " ]"); // Free memory paramsGroup.Dispose(); paramsGroups.Dispose(); dictionary.Dispose(); value.Dispose(); paramsGroup = null; paramsGroups = null; keys = null; dictionary = null; value = null; } catch (Exception e) { return; } }
public void EnumerateTags(NSString rootPath, CGImageMetadataEnumerateOptions options, CGImageMetadataTagBlock block) { IntPtr r = rootPath == null ? IntPtr.Zero : rootPath.Handle; NSDictionary o = null; if (options != null) { o = options.ToDictionary(); } CGImageMetadataEnumerateTagsUsingBlock(Handle, r, o == null ? IntPtr.Zero : o.Handle, block); if (options != null) { o.Dispose(); } }
public CGImageMetadata CopyMetadata(nint index, CGImageOptions options) { NSDictionary o = null; if (options != null) { o = options.ToDictionary(); } var result = CopyMetadata(index, o); if (options != null) { o.Dispose(); } return(result); }
public static bool PrepareFromIntune() { List <string> listaDatos = new List <string> (); try { // Recover configuration parameters from Intune IntuneMAMPolicyManager value = IntuneMAMPolicyManager.Instance; NSDictionary dictionary = value.DiagnosticInformation; NSString[] keys = new NSString[] { new NSString(Mobile.ID_DIC_INTUNE) }; NSDictionary paramsGroups = dictionary.GetDictionaryOfValuesFromKeys(keys); NSObject paramsGroup = paramsGroups.ElementAt(0).Value; var data = Mobile.configData; // Convert parameters to string and regenerate the certificate data.ftpDownload_User = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_USER)).ToString(); data.ftpDownload_Pass = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PASS)).ToString(); data.ftpDownload_Host = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_HOST)).ToString(); data.ftpDownload_Port = int.Parse(paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PORT)).ToString()); data.ftpDownload_Path = paramsGroup.ValueForKey(new NSString(Mobile.ID_FTP_PATH)).ToString(); data.GenerateCert(paramsGroup.ValueForKey(new NSString(Mobile.ID_CERTIFICATE)).ToString()); data.HasIntune = true; Utils.Print("Intune parameters loaded.."); Utils.Print("FTP: " + data.ftpDownload_Host + ":" + data.ftpDownload_Port + " - " + data.ftpDownload_User + " [ " + data.ftpDownload_Pass + " ]"); Utils.Print("Certificate: " + data.certificate.FriendlyName + " [ " + data.certificate.NotAfter + " ]"); // Free memory paramsGroup.Dispose(); paramsGroups.Dispose(); dictionary.Dispose(); value.Dispose(); paramsGroup = null; paramsGroups = null; keys = null; dictionary = null; value = null; } catch (Exception e) { return(false); } return(true); }
public void AddImageAndMetadata(CGImage image, CGImageMetadata meta, CGImageDestinationOptions options) { NSDictionary o = null; if (options != null) { o = options.ToDictionary(); } try { AddImageAndMetadata(image, meta, o); } finally { if (options != null) { o.Dispose(); } } }
public bool CopyImageSource(CGImageSource image, CGCopyImageSourceOptions options, out NSError error) { NSDictionary o = null; if (options != null) { o = options.ToDictionary(); } try { return(CopyImageSource(image, o, out error)); } finally { if (options != null) { o.Dispose(); } } }
private void PictureSelected(NSDictionary pictureDict) { float maxWidth = 100; UIImage Picture; if ((pictureDict[UIImagePickerController.MediaType] as NSString) == "public.image") { Picture = pictureDict[UIImagePickerController.EditedImage] as UIImage; if (Picture == null) { Picture = pictureDict[UIImagePickerController.OriginalImage] as UIImage; } // save a copy of the original picture if (!_isFromGallery) { Picture.SaveToPhotosAlbum(delegate { }); } var size = Picture.Size; // show the UI, and on a callback, do the scaling, so the user gets an animation NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(0), delegate { if (size.Width > maxWidth || size.Height > maxWidth) { Picture = Scale(Picture, new SizeF(maxWidth, (float)(maxWidth * size.Height / size.Width))); } UserImageView.Image = Picture; App.Locator.Parameter.UserPicture = ImageHelper.ImageToByte(Picture); SaveButton.Enabled = true; _hasDataChanged = true; }); } else { //NSUrl movieUrl = pictureDict [UIImagePickerController.MediaURL] as NSUrl; // Future use, when we find a video host that does not require your Twitter login/password } pictureDict.Dispose(); }
/// <summary> /// Checks if media is video or Image. /// If it was an image, get the other image info. /// </summary> /// <param name="picker">Picker.</param> /// <param name="info">Info.</param> public async override void FinishedPickingMedia(UIImagePickerController picker, NSDictionary info) { try { // determine what was selected, video or image bool isImage = false; switch (info[UIImagePickerController.MediaType].ToString()) { case "public.image": isImage = true; break; case "public.video": break; } if (isImage) { UIImage originalImage = info[UIImagePickerController.OriginalImage] as UIImage; if (originalImage != null) { UIImageOrientation OrIn = originalImage.Orientation; Debug.WriteLine("scaling image"); var originalImage1 = await Task.Run(() => ScaleAndRotateImage.ScaleAndRotateImageView(originalImage, OrIn)); if (originalImage1 != null) { var Data = originalImage1.AsJPEG(0.0f); if (Data != null) { UIImage resizedImage = UIImage.LoadFromData(Data); if (originalImage != null) { originalImage.Dispose(); originalImage = null; } originalImage1.Dispose(); originalImage1 = null; Data.Dispose(); Data = null; GC.Collect(); camController.ShowPhoto(resizedImage); } if (info != null) { (info[UIImagePickerController.OriginalImage] as UIImage).CGImage.Dispose(); (info[UIImagePickerController.OriginalImage] as UIImage).Dispose(); info[UIImagePickerController.OriginalImage].Dispose(); info[UIImagePickerController.OriginalImage] = new UIImage(); info.Dispose(); } GC.Collect(); } } } } catch (Exception ex) { Debug.WriteLine("Exception Occured in FinishedPickingMedia method due to " + ex.Message); } finally { // dismiss the picker if (picker != null) { picker.DismissModalViewController(true); picker.Dispose(); picker = null; GC.Collect(); } #if DEBUG var Process1 = Process.GetCurrentProcess(); if (Process1 != null) { Debug.WriteLine(string.Format("memory allocated by FinishedPickingMedia after DismissModalViewController = {0}", Process1.WorkingSet64)); } #endif } }
void PictureSelected(NSDictionary pictureDict) { int level = Util.Defaults.IntForKey("sizeCompression"); if ((pictureDict [UIImagePickerController.MediaType] as NSString) == "public.image") { Picture = pictureDict [UIImagePickerController.EditedImage] as UIImage; if (Picture == null) { Picture = pictureDict [UIImagePickerController.OriginalImage] as UIImage; } // Save a copy of the original picture if (!FromLibrary) { Picture.SaveToPhotosAlbum(delegate { // ignore errors }); } var size = Picture.Size; float maxWidth; switch (level) { case 0: maxWidth = 640; break; case 1: maxWidth = 1024; break; default: maxWidth = size.Width; break; } var hud = new LoadingHUDView(Locale.GetText("Image"), Locale.GetText("Compressing")); View.AddSubview(hud); hud.StartAnimating(); // Show the UI, and on a callback, do the scaling, so the user gets an animation NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(0), delegate { if (size.Width > maxWidth || size.Height > maxWidth) { Picture = Scale(Picture, new SizeF(maxWidth, maxWidth * size.Height / size.Width)); } hud.StopAnimating(); hud.RemoveFromSuperview(); hud = null; }); } else { //NSUrl movieUrl = pictureDict [UIImagePickerController.MediaURL] as NSUrl; // Future use, when we find a video host that does not require your Twitter login/password } pictureDict.Dispose(); }
void PictureSelected(NSDictionary pictureDict) { int level = Util.Defaults.IntForKey ("sizeCompression"); if ((pictureDict [UIImagePickerController.MediaType] as NSString) == "public.image"){ Picture = pictureDict [UIImagePickerController.EditedImage] as UIImage; if (Picture == null) Picture = pictureDict [UIImagePickerController.OriginalImage] as UIImage; // Save a copy of the original picture if (!FromLibrary){ Picture.SaveToPhotosAlbum (delegate { // ignore errors }); } var size = Picture.Size; float maxWidth; switch (level){ case 0: maxWidth = 640; break; case 1: maxWidth = 1024; break; default: maxWidth = size.Width; break; } var hud = new LoadingHUDView (Locale.GetText ("Image"), Locale.GetText ("Compressing")); View.AddSubview (hud); hud.StartAnimating (); // Show the UI, and on a callback, do the scaling, so the user gets an animation NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (0), delegate { if (size.Width > maxWidth || size.Height > maxWidth) Picture = Scale (Picture, new SizeF (maxWidth, maxWidth*size.Height/size.Width)); hud.StopAnimating (); hud.RemoveFromSuperview (); hud = null; }); } else { //NSUrl movieUrl = pictureDict [UIImagePickerController.MediaURL] as NSUrl; // Future use, when we find a video host that does not require your Twitter login/password } pictureDict.Dispose (); }
private void Save(string path, int size, Action<bool> callback, NSDictionary data) { bool result = false; UIImage photo = null; UIImage source = null; NSData file = null; NSError error = null; try { source = data.ObjectForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage; if (source != null) { photo = ScaleImage(source, size); file = photo.AsJPEG(); bool saved = file.Save(path, false, out error); if (!saved) Context.HandleException(new NonFatalException(D.IO_EXCEPTION, error.LocalizedDescription)); result = saved; } } finally { if (photo != null) photo.Dispose(); if (source != null) source.Dispose(); if (file != null) file.Dispose(); if (error != null) error.Dispose(); if (data != null) data.Dispose(); } Task.Run(() => { Thread.Sleep(300); Context.InvokeOnMainThread(() => callback(result)); }); }