# Clip Region

Learn how to clip a region with DsImaging using easy steps and a sample code.

## Content

A clip region refers to a specific part of an image and is defined to limit the drawing operations for an image to a specific part of the image.
In DsImaging, the clip region can be created using the [CreateClipRegion](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Drawing.GcGraphics.CreateClipRegion.html) method of the **GcBitmapGraphics** class which takes a **Rectangle** or a **GraphicsPath** as a parameter. The defined clip region is applied to the image using the [PushClip](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Drawing.GcGraphics.PushClip.html) method which limits the drawing operations to the clip region. After the required drawing operations are done, you can use the [PopClip](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging/GrapeCity.Documents.Drawing.GcGraphics.PopClip.html) method to remove the clip region and make the complete image surface available for any further drawing operations.
![A beautiful home with a clipped region on top right](https://cdn.mescius.io/document-site-files/images/a5680f0e-2d32-45dc-8048-d3ef11d0dae7/images/clippedimage.png)
To clip an image:

1. Create an instance of GcBitmap.
2. Load an image into the GcBitmap instance.
3. Define a clip rectangle for adding text.
4. Add text to the rectangle.
5. Pass the rectangle as a parameter in **PushClip** method of the GcBitmapGraphics class.

    ```csharp
    var backColor = Color.FromArgb(unchecked((int)0xff0066cc));
    var foreColor = Color.FromArgb(unchecked((int)0xffffcc00));
    float cw = 450, ch = 300, pad = 10, bord = 4;
    int pixelWidth = 1024, pixelHeight = 1024;
    
    GcBitmap origBmp = new GcBitmap(pixelWidth, pixelHeight, true);
    var path = Path.Combine("Resources", "Images", "tudor.jpg");
    origBmp.Load(path);
    
    GcBitmapGraphics g = origBmp.CreateGraphics();
    
    RectangleF clipRc = new RectangleF(pixelWidth - cw - pad,
    
        pad, cw, ch);
    
    using (g.PushClip(clipRc))
    {
        g.FillRectangle(clipRc, Color.Blue);
        g.DrawString("This is a beautiful home",
            new TextFormat()
            {
                Font = Font.FromFile(Path.Combine("Resources", 
                "Fonts", "times.ttf")),
                FontSize = 16,
                ForeColor = foreColor
            },
            clipRc
            );
    }
    
    //Save the image with clipped region
    origBmp.SaveAsJpeg("ClipImageTest.jpeg");
    ```

For more information about implementation of clipping using DsImaging, see [DsImaging sample browser](https://developer.mescius.com/documents-api-imaging/demos/basics/drawing/push-clip/code-cs).

> !type=note
> **Note**: For rendering large or complex text and graphics, you can use [Skia](/document-solutions/dot-net-imaging-api/api/online/DS.Documents.Imaging.Skia/GrapeCity.Documents.Imaging.Skia.html) library. For more information about the library and its usage, see [Render using Skia Library](/document-solutions/dot-net-imaging-api/docs/online/render-using-skia).