Vignette is an artistic effect designed to draw attention to the center of the image. Classically vignetting reduces brightness or saturation at the periphery of the image, but vignettes can have different shapes, widths, and colors. This topic describes how to create vignettes using Graphics Mill.

## Classic Vignette

The following image illustrates a classical vignette:

Creating such a vignette includes the following steps:

1. Creating an empty mask image. The image must be of the same size as the decorating image. The pixel format of the mask image should be 8-bit grayscale (or 16-bit grayscale, if the decorating image has extended pixel format).
2. Drawing a hollow ellipse, thick enough to fill all the edges. You can perform this task using the Aurigma.GraphicsMill.AdvancedDrawing.Graphics class.
4. Replacing the alpha channel of the decorating image with the prepared mask and flattening the resulting image.

The following code adds a classical vignette to an image:

C#
using (var bitmap = new Bitmap(@"Images\in.jpg"))
{
using (var mask = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format8bppGrayscale, RgbColor.Black))
{
{
graphics.FillEllipse(new SolidBrush(RgbColor.White), 50, 50, bitmap.Width - 100, bitmap.Height - 100);

//Apply blur transform

//Flatten alpha channel
bitmap.Channels.RemoveAlpha(RgbColor.Black);

bitmap.Save(@"Images\Output\out.jpg");
}
}
}

Note

The described approach opens wide horizons for creativity. For example, it allows you to create vignettes of different shapes (hearts, diamonds, stars, clouds or any other). Using Aurigma.GraphicsMill.AdvancedDrawing.Graphics you can draw curves of almost any shape.

The other technique, which is somewhat slower but offers even more possibilities, is based on combining two images. This technique includes the following steps:

1. Creating an overlaying bitmap, this is an empty bitmap of the same size as the decorating image.
2. Creating an empty grayscale bitmap, this is a mask for the alpha channel of the overlaying bitmap.
3. Drawing a vignette pattern on the mask and applying the desired effects.
4. Replacing the alpha channel of the overlaying bitmap with the mask.
5. Combining the overlaying image with the decorating one. Here you can experiment with combine modes. For example, using the Screen mode gives the pixels under the vignette the same tint as the vignette color, preserving the highlights and shadows of the decorating image.

The following image illustrates an advanced vignette:

C#
using (var bitmap = new Bitmap(@"Images\in.jpg"))
{
//Create an ovelaying bitmap and an empty mask. It will be opaque as it is filled with white
using (var overlay = new Bitmap(bitmap.Width, bitmap.Height,
PixelFormat.Format32bppArgb, RgbColor.Pink))
using (var mask = new Bitmap(bitmap.Width, bitmap.Height,
PixelFormat.Format8bppGrayscale, RgbColor.White))
{
System.Drawing.PointF[] points = {
new System.Drawing.PointF(20, 10),
new System.Drawing.PointF(overlay.Width-20, 10),
new System.Drawing.PointF(overlay.Width-10, 20),
new System.Drawing.PointF(overlay.Width-10, overlay.Height-20),
new System.Drawing.PointF(overlay.Width-20, overlay.Height-10),
new System.Drawing.PointF(20, overlay.Height-10),
new System.Drawing.PointF(10, overlay.Height-20),
new System.Drawing.PointF(10, 20),
new System.Drawing.PointF(20, 10)
};

{
//Draw a polygon
graphics.FillPolygon(new SolidBrush(RgbColor.Black), points);

//Replace the alpha channel of the overlay with the mask

//Put the ovelaying bitmap over the source image
bitmap.Draw(overlay, 0, 0, overlay.Width, overlay.Height,
CombineMode.Screen, 1.0f, ResizeInterpolationMode.High);

bitmap.Save(@"Images\Output\out.jpg");
}
}
}