public override void MouseUp()
 {
     if(fromCreate)
     {
         (pointer.lastCommand as CreateCommand).prim = prim;
     }
     else
     {
         ResizeCommand resizeCommand = new ResizeCommand();
         pointer.commands.Add(resizeCommand);
     }
     MainWindow.window.DeselectDrawItem();
     pointer.ChangeTool(new SelectTool(pointer));
     (pointer.Tool as SelectTool).AddSelection(prim);
 }
예제 #2
0
        public static ImageSource Resize(this ImageSource image, Size maxSize)
        {
            var rasterImage = ToRasterImage(image);
            var currentSize = new Size(rasterImage.ImageSize.Width, rasterImage.ImageSize.Height);
            var newSize = currentSize.PreserveAspectRatioWithinBounds(maxSize);

            var destImage = new RasterImage(
                RasterMemoryFlags.Conventional,
                (int)newSize.Width,
                (int)newSize.Height,
                rasterImage.BitsPerPixel,
                rasterImage.Order,
                rasterImage.ViewPerspective,
                rasterImage.GetPalette(),
                IntPtr.Zero,
                0);

            var cmd = new ResizeCommand(destImage, RasterSizeFlags.Bicubic);
            cmd.Run(rasterImage);
            return ToBitmapSource(destImage);
        }
 private void InitCommands()
 {
     OpenCommand = new OpenCommand(this);
     ApplyCommand = new ApplyCommand(this);
     FlipCommand = new FlipCommand(this);
     HistogramEqualizeCommand = new HistogramEqualizeCommand(this);
     HistogramStretchCommand = new HistogramStretchCommand(this);
     CropCommand = new CropCommand(this);
     InpaintCommand = new InpaintCommand(this);
     ResizeCommand = new ResizeCommand(this);
     RotateCommand = new RotateCommand(this);
     SaveAsCommand = new SaveAsCommand(this);
     SaveCommand = new SaveCommand(this);
     ZoomCommand = new ZoomCommand(this);
     ResetCommand = new ResetCommand(this);
     CloseCommand = new CloseCommand(this);
     SelectToolCommand = new SelectToolCommand(this);
     UndoCommand = new UndoCommand(this);
     RedoCommand = new RedoCommand(this);
     DropboxCommand = new DropboxCommand(this);
     DownloadCommand = new DownloadCommand(this);
     UploadCommand = new UploadCommand(this);
     DCommand = new DCommand(this);
     ECommand = new ECommand(this);
     PrewittCommand = new PrewittCommand(this);
 }