public async Task SaveCropBitmap(StorageFile newImageFile, Size?imageSize = null) { var generalTransform = selectRegion.TransformToVisual(editImage); var cropRect = generalTransform.TransformBounds(CropSelection.SelectedRect); double sourceImageScale = 1; if (this.sourceImagePixelHeight < this.ActualHeight && this.sourceImagePixelWidth < this.ActualWidth) { } else { sourceImageScale = Math.Min(this.ActualWidth / this.sourceImagePixelWidth, this.ActualHeight / this.sourceImagePixelHeight); } var x = cropRect.X / sourceImageScale; var y = cropRect.Y / sourceImageScale; var width = cropRect.Width / sourceImageScale; var height = cropRect.Height / sourceImageScale; await BitmapHelper.SaveCroppedBitmapAsync( this.TempImageFile, newImageFile, new Point(x, y), new Size(width, height), imageSize); }
public async Task SaveCroppedBitmap(StorageFile croppedImageFile, Size?imageSize = null) { double widthScale = imageCanvas.Width / this.sourceImagePixelWidth; double heightScale = imageCanvas.Height / this.sourceImagePixelHeight; await BitmapHelper.SaveCroppedBitmapAsync( this.SourceImageFile, croppedImageFile, new Point(this.CropSelection.SelectedRect.X / widthScale, this.CropSelection.SelectedRect.Y / heightScale), new Size(this.CropSelection.SelectedRect.Width / widthScale, this.CropSelection.SelectedRect.Height / heightScale), imageSize); }
public async Task SaveBitmap(StorageFile newImageFile, Size?imageSize = null) { var generalTransform = selectRegion.TransformToVisual(editImage); var cropRect = generalTransform.TransformBounds(CropSelection.SelectedRect); var width = cropRect.Width / scrollViewer.ZoomFactor; var height = cropRect.Height / scrollViewer.ZoomFactor; await BitmapHelper.SaveCroppedBitmapAsync( this.TempImageFile, newImageFile, new Point(0, 0), new Size(this.sourceImagePixelWidth, this.sourceImagePixelHeight), imageSize); }