private async void btnUpdateSelected_Click(object sender, RoutedEventArgs e) { this.IsEnabled = false; Picture p = Pictures.ElementAt(listPictures.SelectedIndex); p.Source = txtSource.Text; bool withImage = Upload != null; if (Upload != null) { p.FileName = Upload.Name; await Upload.SaveAsync(); p.File = Upload; } await p.SaveAsync(); Upload = null; ListBoxItem item = listPictures.SelectedItem as ListBoxItem; (item.Content as Image).Source = UploadImage; UploadImage = null; this.IsEnabled = true; MessageBox.Show("Picture updated successfully" + (withImage ? " with new image" : "")); }
public async Task <bool> UpdateUser(Dictionary <string, object> parameters, byte[] profilePicture, byte[] coverPicture) { if (parameters != null) { foreach (var parameter in parameters) { ParseUser.CurrentUser [parameter.Key] = parameter.Value; } } if (profilePicture != null) { ParseFile file = new ParseFile("profilePicture.jpg", profilePicture); await file.SaveAsync(); ParseUser.CurrentUser ["profilePicture"] = file; } if (coverPicture != null) { ParseFile file = new ParseFile("coverPicture.jpg", coverPicture); await file.SaveAsync(); ParseUser.CurrentUser ["coverPicture"] = file; } try { await ParseUser.CurrentUser.SaveAsync(); return(true); } catch (Exception e) { return(false); } }
public async Task CreateUserAsync(string username, string email, string password, byte[] profilepic) { if (username != "" && email != "" && password != "" && profilepic != null) { ParseFile file = new ParseFile("avatar.jpg", profilepic); try { await file.SaveAsync(); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } var user = new ParseUser() { Username = username, Password = password, Email = email }; user ["ProfilePic"] = file; try { await user.SignUpAsync(); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } } }
private async void btn_update_Click_1(object sender, RoutedEventArgs e) { if (txt_caption1.Text.Equals("")) { MessageBoxResult result = MessageBox.Show("Please input caption."); return; } else if (txt_image1.Text.Equals("") || txt_image2.Text.Equals("")) { MessageBoxResult result = MessageBox.Show("Please select images."); return; } byte[] data1 = this.ConvertImageToByte(m_bitmap1); ParseFile file1 = new ParseFile("1.png", data1); await file1.SaveAsync(); byte[] data2 = this.ConvertImageToByte(m_bitmap2); ParseFile file2 = new ParseFile("2.png", data2); await file2.SaveAsync(); var NFCreg = m_RegList[nSelectionIndex]; NFCreg["NFC_id"] = txt_id.Text; NFCreg["linked_user"] = "******"; NFCreg["Caption"] = txt_caption1.Text; NFCreg["File1"] = file1; NFCreg["File2"] = file2; await NFCreg.SaveAsync(); MessageBox.Show("Update finish!"); RefreshList(); }
public Task TestFileSave() { Mock <IParseFileController> mockController = new Mock <IParseFileController>(); mockController.Setup(obj => obj.SaveAsync(It.IsAny <FileState>(), It.IsAny <Stream>(), It.IsAny <string>(), It.IsAny <IProgress <IDataTransferLevel> >(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(new FileState { Name = "newBekti.png", Location = new Uri("https://www.parse.com/newBekti.png"), MediaType = "image/png" })); Mock <IParseCurrentUserController> mockCurrentUserController = new Mock <IParseCurrentUserController>(); ParseClient client = new ParseClient(new ServerConnectionData { Test = true }, new MutableServiceHub { FileController = mockController.Object, CurrentUserController = mockCurrentUserController.Object }); ParseFile file = new ParseFile("bekti.jpeg", new MemoryStream { }, "image/jpeg"); Assert.AreEqual("bekti.jpeg", file.Name); Assert.AreEqual("image/jpeg", file.MimeType); Assert.IsTrue(file.IsDirty); return(file.SaveAsync(client).ContinueWith(task => { Assert.IsFalse(task.IsFaulted); Assert.AreEqual("newBekti.png", file.Name); Assert.AreEqual("image/png", file.MimeType); Assert.AreEqual("https://www.parse.com/newBekti.png", file.Url.AbsoluteUri); Assert.IsFalse(file.IsDirty); })); }
// Use this for initialization public void photo() { Loom.QueueOnMainThread(() => { if (img == null) { byte[] data = img1.EncodeToJPG(); ParseFile file = new ParseFile("none.jpg", data); file.SaveAsync().ContinueWith(t => { Debug.Log(file.Name); createnewaccount(file); }); } else { byte[] data = img.EncodeToJPG(); ParseFile file = new ParseFile("photo.jpg", data); file.SaveAsync().ContinueWith(t => { Debug.Log(file.Name); createnewaccount(file); }); } }); }
public Task TestFileSave() { Mock <IParseFileController> mockController = new Mock <IParseFileController>(); mockController.Setup(obj => obj.SaveAsync(It.IsAny <FileState>(), It.IsAny <Stream>(), It.IsAny <string>(), It.IsAny <IProgress <ParseUploadProgressEventArgs> >(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(new FileState { Name = "newBekti.png", Url = new Uri("https://www.parse.com/newBekti.png"), MimeType = "image/png" })); Mock <IParseCurrentUserController> mockCurrentUserController = new Mock <IParseCurrentUserController>(); ParseCorePlugins.Instance = new ParseCorePlugins { FileController = mockController.Object, CurrentUserController = mockCurrentUserController.Object }; ParseFile file = new ParseFile("bekti.jpeg", new MemoryStream(), "image/jpeg"); Assert.AreEqual("bekti.jpeg", file.Name); Assert.AreEqual("image/jpeg", file.MimeType); Assert.IsTrue(file.IsDirty); return(file.SaveAsync().ContinueWith(t => { Assert.IsFalse(t.IsFaulted); Assert.AreEqual("newBekti.png", file.Name); Assert.AreEqual("image/png", file.MimeType); Assert.AreEqual("https://www.parse.com/newBekti.png", file.Url.AbsoluteUri); Assert.IsFalse(file.IsDirty); })); }
public async void storeAttachmentOnDataBaseAsync() { System.Console.Write("CHEGOU"); await parseFile.SaveAsync(); System.Console.Write("CHEGOU 2222222"); bool owner = isMine; ParseObject objClass = new ParseObject("usersChats"); //sempre guardar com o "menor" nome em ordem alfabética como "user1" if (sender.CompareTo(receiver) < 0) { objClass["user1"] = ParseObject.CreateWithoutData("_User", sender); objClass["user2"] = ParseObject.CreateWithoutData("_User", receiver); } else { objClass["user1"] = ParseObject.CreateWithoutData("_User", receiver); objClass["user2"] = ParseObject.CreateWithoutData("_User", sender); owner = !owner; } objClass["createdAt"] = date; objClass["isMine"] = owner; objClass["attach"] = parseFile; objClass["message"] = ""; await objClass.SaveAsync(); }
public async void saveFile(string fileName, Stream stream, Action <string> callback) { var file = new ParseFile(fileName, stream); await file.SaveAsync(); callback(file.Url.AbsoluteUri.ToString()); }
private async void btnAceptar(object sender, RoutedEventArgs e) { if (file != null) { var stream = await file.OpenAsync(FileAccessMode.Read); ParseFile fileP = new ParseFile(file.Name, stream.AsStream()); await fileP.SaveAsync(); FotoMascota foto = new FotoMascota(); foto.Url = fileP.Url.OriginalString; foto.IdMascota = mascota.Id; var imagenMascota = new ParseObject(FotoMascota.TABLA) { { FotoMascota.IDMASCOTA, mascota.Id }, { FotoMascota.IMAGEN, fileP }, }; await imagenMascota.SaveAsync(); foto.Id = imagenMascota.ObjectId; mascota.Fotos.Add(foto); rootFrame.GoBack(); } else { var dlg = new Windows.UI.Popups.MessageDialog("Debe seleccionar una imagen."); await dlg.ShowAsync(); } }
public void sub() { Loom.QueueOnMainThread(() => { if (img == null) { byte[] data = img1.EncodeToPNG(); ParseFile file = new ParseFile("none.png", data); file.SaveAsync().ContinueWith(t => { Debug.Log(file.Name); UpdateOldUser(file); }); //Task saveTask = file.SaveAsync(); //UpdateOldUser (file); } else { byte[] data = img.EncodeToPNG(); ParseFile file = new ParseFile("photo.png", data); file.SaveAsync().ContinueWith(t => { Debug.Log(file.Name); UpdateOldUser(file); }); //Task saveTask = file.SaveAsync(); //UpdateOldUser (file); } }); //UpdateOldUser (file); }
private async void btnAceptar(object sender, RoutedEventArgs e) { if (file != null && nombre.Text != "" && descripcion.Text != "") { var stream = await file.OpenAsync(FileAccessMode.Read); ParseFile fileP = new ParseFile(file.Name, stream.AsStream()); await fileP.SaveAsync(); ObservableCollection <FotoMascota> fotos = new ObservableCollection <FotoMascota>(); Mascota mascota = new Mascota(); FotoMascota foto = new FotoMascota(); foto.Url = fileP.Url.OriginalString; mascota.Nombre = nombre.Text; mascota.Tipo = tipomascota; mascota.NombreUsuario = ParseUser.CurrentUser.Username; mascota.Descripcion = descripcion.Text; mascota.Edad = comboEdad.SelectedItem as string; if (descripcion.Text.Length > 45) { mascota.DescripcionCorta = descripcion.Text.Substring(0, 45); } else { mascota.DescripcionCorta = descripcion.Text; } var parseMascota = new ParseObject(Mascota.TABLA) { { Mascota.TIPO, tipomascota }, { Mascota.NOMBRE, nombre.Text }, { Mascota.NOMBREUSUARIO, ParseUser.CurrentUser.Username }, { Mascota.DESCRIPCION, descripcion.Text }, { Mascota.EDAD, comboEdad.SelectedItem }, }; await parseMascota.SaveAsync(); mascota.Id = parseMascota.ObjectId; foto.IdMascota = parseMascota.ObjectId; var imagenMascota = new ParseObject(FotoMascota.TABLA) { { FotoMascota.IDMASCOTA, parseMascota.ObjectId }, { FotoMascota.IMAGEN, fileP }, }; await imagenMascota.SaveAsync(); foto.Id = imagenMascota.ObjectId; fotos.Add(foto); mascota.Fotos = fotos; principalPage.notificarSeAgregoLaMascota(mascota); rootFrame.GoBack(); } else { var dlg = new Windows.UI.Popups.MessageDialog("Por favor ingrese todos los campos."); await dlg.ShowAsync(); } }
public async Task <bool> Signup(User user, byte[] profilePicture) { try { var newUser = new ParseUser() { Email = user.Email, Username = user.Email, Password = user.Password, }; newUser.Add("name", user.Name); if (profilePicture != null) { ParseFile file = new ParseFile("profilePicture.jpg", profilePicture); await file.SaveAsync(); newUser.Add("profilePicture", file); } await newUser.SignUpAsync(); } catch (ParseException pex) { string exMessage; if (pex.Code == ParseException.ErrorCode.UsernameTaken) { exMessage = pex.Message; } else if (pex.Code == ParseException.ErrorCode.EmailTaken) { exMessage = pex.Message; } else { exMessage = pex.Message; } AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.AppContext); alert.SetTitle(AppConfig.ApplicationName); alert.SetMessage(exMessage); alert.SetPositiveButton("OK", (senderAlert, args) => { }); alert.Show(); } catch (InvalidOperationException inv) { AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.AppContext); alert.SetTitle(AppConfig.ApplicationName); alert.SetMessage(inv.Message); alert.SetPositiveButton("OK", (senderAlert, args) => { }); alert.Show(); } catch (Exception ex) { AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.AppContext); alert.SetTitle(AppConfig.ApplicationName); alert.SetMessage(ex.Message); alert.SetPositiveButton("OK", (senderAlert, args) => { }); alert.Show(); } return(IsLoggedIn()); }
private IEnumerator ScreenShoot() { //Wait for graphics to render yield return(new WaitForEndOfFrame()); RenderTexture rt = new RenderTexture(Screen.width, Screen.height, 24); Texture2D screenShot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); //Render from all! //foreach (Camera cam in Camera.allCameras) //{ Camera.main.targetTexture = rt; Camera.main.Render(); Camera.main.targetTexture = null; //} RenderTexture.active = rt; screenShot.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); Camera.main.targetTexture = null; //Added to avoid errors RenderTexture.active = null; Destroy(rt); //Split the process up--ReadPixels() and the GetPixels() call inside of the encoder are both pretty heavy yield return(0); byte[] bytes = screenShot.EncodeToPNG(); ParseFile file = new ParseFile(getNumberId() + ".png", bytes); file.SaveAsync().ContinueWith(t => { Debug.Log(t.IsFaulted); if (!t.IsFaulted) { fileSaved = true; } else { Debug.Log(t.Exception.Message); Debug.LogException(t.Exception); } }); tempFile = file; //storeData.imageFiles.Add(file); //Texture2D texture = new Texture2D(Screen.width, Screen.height); //texture.LoadImage(bytes); //Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); //screenShotImg.sprite = sprite; }
public async void UploadImage(string path) { try { byte[] b = System.IO.File.ReadAllBytes(path); ParseFile imgfile = new ParseFile(path, b); await imgfile.SaveAsync(); } catch (Exception e) { Console.WriteLine(e.Message); } }
// Use this for initialization public void uploadphoto() { byte[] data = img.EncodeToJPG(); ParseFile file = new ParseFile("photo.jpg", data); file.SaveAsync().ContinueWith(t => { Debug.Log(file.Name); Updatenewphoto(file); }); }
protected ParseFile Upload(FileUpload fupload) { string uploadFileName = Path.GetFileName(fupload.PostedFile.FileName); FileInfo Finfo = new FileInfo(fupload.PostedFile.FileName); string extension = Finfo.Extension.ToLower(); byte[] data = fupload.FileBytes; ParseFile file = new ParseFile("question" + Tutor.Get <int>("numQuestionsCreated") + extension, data); Task t = file.SaveAsync(); t.Wait(); return(file); }
public async void SaveParseImage(string imgPath, string fileName) { try { ParseUser user = ParseUser.CurrentUser; byte[] b = System.IO.File.ReadAllBytes(imgPath); ParseFile imgfile = new ParseFile(fileName, b); await imgfile.SaveAsync(); } catch (Exception e) { Console.WriteLine(e.Message); } }
IEnumerator UploadFile(byte[] data) { ParseFile file = new ParseFile(_item.Name + ".png", data); Task task = file.SaveAsync(); while (!task.IsCompleted) { yield return(null); } _item.Image = file; LoadAlert.Instance.Done(); }
void ea_PauseEvent(object sender, EventArgs e) { Target.GetComponent <TargetController>().Stop(); Utility.Log("Done ea'ing (and neat'ing)"); XmlWriterSettings _xwSettings = new XmlWriterSettings(); _xwSettings.Indent = true; // Save genomes to xml file. DirectoryInfo dirInf = new DirectoryInfo(Application.persistentDataPath + "/" + Parse.ParseUser.CurrentUser.Username); if (!dirInf.Exists) { Debug.Log("Creating subdirectory"); dirInf.Create(); } using (XmlWriter xw = XmlWriter.Create(popFileSavePath, _xwSettings)) { experiment.SavePopulation(xw, _ea.GenomeList); } // Also save the best genome using (XmlWriter xw = XmlWriter.Create(champFileSavePath, _xwSettings)) { experiment.SavePopulation(xw, new NeatGenome[] { _ea.CurrentChampGenome }); } DateTime endTime = DateTime.Now; Utility.Log("Total time elapsed: " + (endTime - startTime)); System.IO.StreamReader stream = new System.IO.StreamReader(popFileSavePath); ParseFile file = new ParseFile(string.Format("{0}.pop.xml", Settings.Brain.ObjectId), stream.BaseStream); Task sTask = file.SaveAsync(); Settings.Brain.Population = file; stream = new System.IO.StreamReader(champFileSavePath); ParseFile pfile = new ParseFile(string.Format("{0}.champ.xml", Settings.Brain.ObjectId), stream.BaseStream); Task task = pfile.SaveAsync(); Settings.Brain.Generation = (int)Generation; Settings.Brain.BestFitness = (float)LastFitness; Settings.Brain.ChampionGene = pfile; Settings.Brain.IsNewBrain = false; Settings.Brain.SaveAsync(); EAStopped(this, EventArgs.Empty); EARunning = false; }
public async Task GetFacebookUserData(string name, string email, string picture) { var webClient = new WebClient(); var profilePicture = webClient.DownloadData(picture); ParseFile file = new ParseFile("profilePicture.jpg", profilePicture); await file.SaveAsync(); ParseUser.CurrentUser ["profilePicture"] = file; ParseUser.CurrentUser ["email"] = email; ParseUser.CurrentUser ["name"] = name; await ParseUser.CurrentUser.SaveAsync(); }
public async Task<ParseFile> UploadFileAsync(ParseFile file) { try { await file.SaveAsync(); return file; } catch (Exception ex) { var msg = ex.Message; return null; } }
public async void updateFundacion(Fundacion fundacion) { ParseObject e = await FundacionById(fundacion.ObjectId); var stream = await fundacion.ArchivoImg.OpenAsync(FileAccessMode.Read); ParseFile fileP = new ParseFile(fundacion.ArchivoImg.Name, stream.AsStream()); await fileP.SaveAsync(); e["foto"] = fileP; e["nombre"] = fundacion.Nombre; e["direccion"] = fundacion.Direccion; e["descripcion"] = fundacion.Descripcion; e["cuenta_bancaria"] = fundacion.Cuenta_bancaria; e["correo"] = fundacion.Correo; e["telefono"] = fundacion.Telefono; await e.SaveAsync(); }
private async void AvatarFromCamera(IUICommand command) { var ui = new CameraCaptureUI(); ui.PhotoSettings.CroppedAspectRatio = new Size(4, 3); var file = await ui.CaptureFileAsync(CameraCaptureUIMode.Photo); if (file != null) { IRandomAccessStream fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); var parseObject = new ParseFile(Guid.NewGuid() + ".jpg", fileStream.AsStreamForRead()); await parseObject.SaveAsync(); AssigneAvatarToModel(parseObject.Url.AbsoluteUri); } }
// 등록 private async void btn_regist_Click_1(object sender, RoutedEventArgs e) { if (txt_caption1.Text.Equals("")) { MessageBoxResult result = MessageBox.Show("Please input caption."); return; } else if (txt_image1.Text.Equals("") || txt_image2.Text.Equals("")) { MessageBoxResult result = MessageBox.Show("Please select images."); return; } foreach (ParseObject PO in m_RegList) { if (txt_id.Text.Equals(PO.Get <string>("NFC_id"))) { MessageBoxResult result = MessageBox.Show("Current NFC id is already exist."); return; } } byte[] data1 = this.ConvertImageToByte(m_bitmap1); ParseFile file1 = new ParseFile("1.png", data1); await file1.SaveAsync(); byte[] data2 = this.ConvertImageToByte(m_bitmap2); ParseFile file2 = new ParseFile("2.png", data2); await file2.SaveAsync(); var NFCreg = new ParseObject("NFC_reg"); NFCreg["NFC_id"] = txt_id.Text; NFCreg["linked_user"] = "******"; NFCreg["Caption"] = txt_caption1.Text; NFCreg["File1"] = file1; NFCreg["File2"] = file2; await NFCreg.SaveAsync(); MessageBox.Show("Regist finish!"); RefreshList(); }
public async Task <Boolean> AddPost(string Description, byte[] Postpic) { try { ParseFile file = new ParseFile("postpic.jpg", Postpic); await file.SaveAsync(); ParseObject Post = new ParseObject("Post"); Post["Description"] = Description; Post["Image"] = file; Post["User"] = ParseUser.CurrentUser; await Post.SaveAsync(); return(true); } catch (Exception e) { Console.WriteLine("Error: " + e.Message); return(false); } }
IEnumerator UploadImage(byte[] data) { LoadAlert.Instance.StartLoad("Uploading photo...", null, -1); ParseFile file = new ParseFile(_item.Name + ".png", data); Task task = file.SaveAsync(); while (!task.IsCompleted) { yield return(null); } LoadAlert.Instance.Done(); if (task.Exception == null) { DefaultAlert.Present("Sorry!", "An error occurred while uploading your photo. Please try again"); } else { _item.Image = file; task = _item.SaveAsync(); while (!task.IsCompleted) { yield return(null); } if (task.Exception == null) { Texture2D tex = new Texture2D(1, 1); tex.LoadImage(data); Image.texture = tex; } else { DefaultAlert.Present("Sorry!", "An error occurred while uploading your photo. Please try again"); } } }
private async void AvatarFromFile(IUICommand command) { var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".png"); var file = await openPicker.PickSingleFileAsync(); if (file != null) { var falKey = StorageApplicationPermissions.FutureAccessList.Add(file); var fileStream = await file.OpenAsync(FileAccessMode.Read); var parseObject = new ParseFile(Guid.NewGuid() + ".jpg", fileStream.AsStreamForRead()); await parseObject.SaveAsync(); AssigneAvatarToModel(parseObject.Url.AbsoluteUri); } }
private async void updateButton_Tapped(object sender, TappedRoutedEventArgs e) { progress.IsIndeterminate = true; try { if (!string.IsNullOrEmpty(name.Text) && kindCombobox.SelectedItem != null && breedcombobox.SelectedItem != null) { var model = new PetModel() { ObjectId = pet.ObjectId, Name = name.Text, Kind = kindCombobox.SelectedItem.ToString(), Breed = breedcombobox.SelectedItem.ToString(), User = ParseUser.CurrentUser, BirthDate = birthdateDatePicker.Date.DateTime }; if (petImage != null) { ParseFile file = new ParseFile("petImage", petImage); await file.SaveAsync(); model.Picture = file; } await DataClient.Instance.UpdatePet(model); backgroundPanel.Visibility = Visibility.Visible; updateInfoPanel.DataContext = model.Name; updateInfoPanel.Visibility = Visibility.Visible; } } catch (Exception) { } progress.IsIndeterminate = false; }
private async void SaveChallenge(object sender, EventArgs e) { var geoPoint = new ParseGeoPoint(geoPosition.Coordinate.Latitude, geoPosition.Coordinate.Longitude); if (geoPoint.Equals(new ParseGeoPoint())) { MessageBox.Show("Still finding your location. Please try again..."); } else if (ChallengeTitle.Text.Trim() == "") { MessageBox.Show("You need to name the comment."); } else { App.PhotoResult.ChosenPhoto.Seek(0, SeekOrigin.Begin); var image = new ParseFile(System.IO.Path.GetFileName(App.PhotoResult.OriginalFileName), App.PhotoResult.ChosenPhoto); await image.SaveAsync(new Progress()); App.PhotoResult.ChosenPhoto.Close(); var challenge = new ParseObject("Challenge") { { "user", ParseUser.CurrentUser }, { "title", ChallengeTitle.Text }, { "image", image }, { "geoPoint", geoPoint } }; await challenge.SaveAsync(); if (challenge.ObjectId != "") { NavigationService.Navigate(new Uri("/Home.xaml?id=" + challenge.ObjectId, UriKind.Relative)); } else { MessageBox.Show("We couldn't save the comment. Please try again."); } } }
protected void Upload(object sender, EventArgs e) { if (FileUpload1.HasFile) { string uploadFileName = Path.GetFileName(FileUpload1.PostedFile.FileName); FileInfo Finfo = new FileInfo(FileUpload1.PostedFile.FileName); string extension = Finfo.Extension.ToLower(); byte[] data = FileUpload1.FileBytes; byte[] square; var sourceImage = CodeCarvings.Piczard.ImageArchiver.LoadImage(data); if (sourceImage.Size.Width == sourceImage.Size.Height) { square = data; } else { // Calculate the square size int imageSize = sourceImage.Size.Width < sourceImage.Size.Height ? sourceImage.Size.Width : sourceImage.Size.Height; // Get a fixed resize filter (square) //var filter = new CodeCarvings.Piczard.FixedResizeConstraint(imageSize, imageSize); var filter = new CodeCarvings.Piczard.FixedCropConstraint(imageSize, imageSize); // Force white background filter.CanvasColor = BackgroundColor.GetStatic(System.Drawing.Color.White); square = filter.SaveProcessedImageToByteArray(sourceImage, new CodeCarvings.Piczard.JpegFormatEncoderParams(82)); } ParseFile file = new ParseFile("profile_picture" + extension, square); Task t = file.SaveAsync(); t.Wait(); theirPublicUserData.ProfilePic = file; Task t2 = theirPublicUserData.SaveAsync(); t2.Wait(); Image1.ImageUrl = theirPublicUserData.ProfilePic != null?theirPublicUserData.ProfilePic.Url.ToString() : "Images/default_prof_pic.png"; } }