System.Drawing.Graphics.SetClip C# (CSharp) Method

SetClip() public method

public SetClip ( Graphics g ) : void
g Graphics
return void
        public void SetClip(Graphics g)
        {
            SetClip (g, CombineMode.Replace);
        }

Same methods

Graphics::SetClip ( Graphics g, CombineMode combineMode ) : void
Graphics::SetClip ( GraphicsPath graphicsPath ) : void
Graphics::SetClip ( GraphicsPath graphicsPath, CombineMode combineMode ) : void
Graphics::SetClip ( Rectangle rect ) : void
Graphics::SetClip ( Rectangle rect, CombineMode combineMode ) : void
Graphics::SetClip ( RectangleF rect ) : void
Graphics::SetClip ( RectangleF rect, CombineMode combineMode ) : void
Graphics::SetClip ( Region region, CombineMode combineMode ) : void

Usage Example

Example #1
2
        public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
        {
            Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);

            if (applyRect.Width == 0 || applyRect.Height == 0)
            {
                // nothing to do
                return;
            }
            GraphicsState state = graphics.Save();
            if (Invert)
            {
                graphics.SetClip(applyRect);
                graphics.ExcludeClip(rect);
            }
            ColorMatrix grayscaleMatrix = new ColorMatrix(new[] {
                new[] {.3f, .3f, .3f, 0, 0},
                new[] {.59f, .59f, .59f, 0, 0},
                new[] {.11f, .11f, .11f, 0, 0},
                new float[] {0, 0, 0, 1, 0},
                new float[] {0, 0, 0, 0, 1}
            });
            using (ImageAttributes ia = new ImageAttributes())
            {
                ia.SetColorMatrix(grayscaleMatrix);
                graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia);
            }
            graphics.Restore(state);
        }
All Usage Examples Of System.Drawing.Graphics::SetClip