예제 #1
0
 private void ApplyEffects(WriteableBitmap croppedResizedWB, Action <WriteableBitmap> callback)
 {
     Stopwatch.StartNew();
     if (croppedResizedWB == null)
     {
         if (this._currentEffects.CropRect != null || this._currentEffects.RotateAngle != 0.0)
         {
             croppedResizedWB = this.ReadCroppedImage();
         }
         else
         {
             croppedResizedWB = this.ReadOriginalImage("", -1);
         }
     }
     croppedResizedWB = this.ApplyContrastIfNeeded(croppedResizedWB);
     this.ApplyFilterIfNeeded(croppedResizedWB, delegate(WriteableBitmap filteredWB)
     {
         Execute.ExecuteOnUIThread(delegate
         {
             filteredWB = this.ApplyTextIfNeeded(filteredWB);
             ImageEditorViewModel.SaveWB(filteredWB, this.GetPathForEffects(this._albumId, this._seqNo));
             callback.Invoke(filteredWB);
             croppedResizedWB = null;
             filteredWB       = null;
             GC.Collect();
         });
     });
 }
예제 #2
0
        public void SetCrop(double rotate, CropRegion rect, WriteableBitmap imSource, Action <BitmapSource> callback)
        {
            if (this.ApplyingEffects)
            {
                return;
            }
            this.ApplyingEffects = true;
            Action <WriteableBitmap> _9__1 = null;

            Deployment.Current.Dispatcher.BeginInvoke(delegate
            {
                WriteableBitmap imSource2 = imSource;
                Picture galleryImage      = this.GetGalleryImage(this._albumId, this._seqNo);
                bool flag  = false;
                double num = this.GetCorrectImageSize(galleryImage, this._albumId, this._seqNo, out flag).Width / (double)imSource2.PixelWidth;
                galleryImage.Dispose();
                WriteableBitmap writeableBitmap = imSource2.Crop((int)((double)rect.X / num), (int)((double)rect.Y / num), (int)((double)rect.Width / num), (int)((double)rect.Height / num));
                Rect rect2 = RectangleUtils.ResizeToFit(new Rect(default(Point), this.ViewportSize), new Size((double)writeableBitmap.PixelWidth, (double)writeableBitmap.PixelHeight));
                WriteableBitmap writeableBitmap2 = writeableBitmap.Resize((int)rect2.Width, (int)rect2.Height, Interpolation.Bilinear);
                ImageEditorViewModel.SaveWB(writeableBitmap2, this.GetPathForCrop());
                this._currentEffects.CropRect    = rect;
                this._currentEffects.RotateAngle = rotate;
                ImageEditorViewModel arg_167_0   = this;
                WriteableBitmap arg_167_1        = writeableBitmap2;
                Action <WriteableBitmap> arg_167_2;
                if ((arg_167_2 = _9__1) == null)
                {
                    arg_167_2 = (_9__1 = delegate(WriteableBitmap bitmap)
                    {
                        callback.Invoke(bitmap);
                        this.ApplyingEffects = false;
                    });
                }
                arg_167_0.ApplyEffects(arg_167_1, arg_167_2);
                this.CallPropertyChanged();
            });
        }