/// <summary> /// Executes the OverlayCommand command. /// </summary> public void ExecuteOverlayCommand() { // create the processing command OverlayCommand command = new OverlayCommand(); // set properties of command PropertyGridForm propertyGridForm = new PropertyGridForm(command, "Overlay Command Properties", true); if (propertyGridForm.ShowDialog() != DialogResult.OK) { return; } // save a reference to the overlay image, image will be disposed when command is finished _overlayImage = command.OverlayImage; // execute the command ExecuteProcessingCommand(command, true); }
/// <summary> /// Returns "Crop to custom selection" composite command. /// </summary> /// <param name="path">Custom selection path.</param> /// <param name="pathBounds">Selection path bounds.</param> /// <param name="crop">Crop command.</param> /// <returns>Crop command for custom selection.</returns> ProcessingCommandBase GetCropToPathCommand( GraphicsPath path, RectangleF pathBounds, CropCommand crop) { Rectangle viewerImageRect = new Rectangle(0, 0, _viewer.Image.Width, _viewer.Image.Height); crop.RegionOfInterest = new RegionOfInterest(GetBoundingRect(RectangleF.Intersect(pathBounds, viewerImageRect))); // overlay command _overlayImage = crop.Execute(_viewer.Image); OverlayCommand overlay = new OverlayCommand(_overlayImage); // overlay with path command ProcessPathCommand overlayWithPath = new ProcessPathCommand(overlay, path); // clear image command ClearImageCommand clearImage = new ClearImageCommand(Color.Transparent); // create composite command: clear, overlay with path, crop return(new CompositeCommand(clearImage, overlayWithPath, crop)); }
/// <summary> /// Draws the barcode image on an image in image viewer. /// </summary> public void DrawBarcodeImage() { if (ImageViewer != null && ImageViewer.Image != null && BarcodeImage != null && !Rectangle.Size.IsEmpty) { VintasoftImage image = ImageViewer.Image; OnImageChanging(new ImageChangedEventArgs(image)); VintasoftImage barcodeImage = BarcodeImage; bool needDisposeBarcodeImage = false; Rectangle barcodeRect = GetDestBarcodeImageRectangle(); // if image size not equals with rectangle size if (barcodeRect.Width != BarcodeImage.Width || barcodeRect.Height != BarcodeImage.Height) { // resize barcode image needDisposeBarcodeImage = true; ResizeCommand resize = new ResizeCommand(barcodeRect.Width, barcodeRect.Height); barcodeImage = resize.Execute(barcodeImage); } // draw barcode image on viewer image OverlayCommand overaly = new OverlayCommand(barcodeImage, barcodeRect.Location); overaly.ExecuteInPlace(image); if (needDisposeBarcodeImage) { barcodeImage.Dispose(); } Rectangle = Rectangle.Empty; OnImageChanged(new ImageChangedEventArgs(image)); } }