Draw With Clipping Path

Drawing Bitmap

Draws an image onto a Graphics object using a clipping path.

Сode Snippet

using (var background = new Bitmap(600, 450, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = background.GetAdvancedGraphics())
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");
}

Output

RestrictDrawingRegion.png

For AI-assisted development: Download Graphics Mill Code Samples XML Catalog