public override void Fill(AnnContainer container, LeadRectD bounds, string color)
        {
            if (_image == null)
            {
                return;
            }

            try
            {
                var fill = new FillCommand(RasterColor.Black);
                _image.AddRectangleToRegion(null, bounds.ToLeadRect(), RasterRegionCombineMode.Set);
                fill.Run(_image);
            }
            finally
            {
                _image.MakeRegionEmpty();
            }
        }
Exemple #2
0
        private void _invertImageUnderOverlayRectButton_Click(object sender, EventArgs e)
        {
            RasterImage image = _imageViewer.Image;

            // Add the overlay rect as a region to the image

            // The overlay rect is in image coordinates already but it is at top-left
            // view perspective, the image might not be. If you load a BMP file or click
            // the fast rotate buttons, you will notice this.

            // We can do one of two things:

            // 1. Use RasterRegionXForm to tell the AddRectangleToRegion method the
            // rect passed is in TopLeft:

            /*
             * RasterRegionXForm xForm = RasterRegionXForm.Default;
             * xForm.ViewPerspective = RasterViewPerspective.TopLeft;
             * image.AddRectangleToRegion(xForm, _overlayRect, RasterRegionCombineMode.Set);
             */

            // RasterRegionXForm is a matrix that allows you to perform many more actions,
            // such as transform the rectangle from any coordinates to another.

            // 2. Use RasterImage.RectangleToImage to convert the rect from TopLeft
            // to the view perspective of the image:
            LeadRect dataRect = image.RectangleToImage(RasterViewPerspective.TopLeft, _overlayRect);

            image.AddRectangleToRegion(null, dataRect, RasterRegionCombineMode.Set);

            InvertCommand cmd = new InvertCommand();

            cmd.Run(image);

            // Remove the region
            image.MakeRegionEmpty();
        }