---
title: "Draw With Clipping Path"
canonical: https://www.graphicsmill.com/samples/Drawing/ClippingPaths/DrawWithClippingPath_cs
product: "Graphics Mill"
source: "Drawing/ClippingPaths/DrawWithClippingPath.cs"
---

# Draw With Clipping Path

Draws an image onto a Graphics object using a clipping path.

## Instruction

Restrict the drawing region to an elliptical area using clipping paths, and draw an image within this restricted area.

## Usings

```csharp
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
using (var background = new Bitmap(600, 450, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = background.GetGraphics())
using (var bitmap = new Bitmap("Chicago.jpg"))
{
    var path = new Path();
    path.DrawEllipse(0f, 0f, background.Width, background.Height);

    graphics.ClippingPaths.Add(path);
    graphics.DrawImage(bitmap, 0f, 0f);

    background.Save("RestrictDrawingRegion.png");
}
```

## Explanation

The code:

- Creates a white background bitmap with specified dimensions.
- Initializes advanced graphics and defines an elliptical clipping path covering the entire background.
- Loads a source image and draws it, constrained to the elliptical region.
- Saves the result to an output image file.

## Tags

- [Bitmap](<https://www.graphicsmill.com/samples/tags/bitmap_md>): Working with images via the Bitmap API
- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text

## Output

- [RestrictDrawingRegion.png](<https://www.graphicsmill.com/samples/Drawing/compiled/Debug/RestrictDrawingRegion_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.ClippingPaths](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Graphics_ClippingPaths.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawImage(Bitmap,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawImage_3_b9413d4f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Path.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path.DrawEllipse(Single,Single,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Path_DrawEllipse_4_37f6c741.htm.md>)
