Applies a shadow effect to an image.
Namespace:
Aurigma.GraphicsMill.Transforms
Assembly:
Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
public sealed class Shadow : Transform
When you apply this effect, the image drops a shadow with specified parameters (taking into account transparent areas of the image). This effect is ideal for creating artistic texts, logos, etc.
You can specify a number of shadow parameters. HorizontalOffset and VerticalOffset specify offset of the shadow relatively the image. Color means the shadow color. To make shadow looking more realistic, it is blurred. You can set blur Radius (amount of the shadow fuzziness). Property EnlargeToFit can be used to specify if the transform should increase size of the image to fit the shadow or it should truncate the shadow which is out of the original image (makes sense to set it to true
when you create artistic thumbnails).
If the bitmap does not have an alpha channel (e.g. its pixel format is Format24bppRgb), alpha channel is automatically added. So be aware that pixel format of the output bitmap may differ from the input one.
The following code gets the thumbnail from an image EXIF metadata, applies the Shadow transform on it, and saves the result:
using (var jpegReader = new JpegReader(@"Images\in.jpg")) { using (var thumbnail = (Bitmap)(jpegReader.Exif[ExifDictionary.Thumbnail])) { //Add the alpha channel if (!thumbnail.HasAlpha) thumbnail.Channels.SetAlpha(1); //Apply Shadow transform thumbnail.Transforms.Shadow(RgbColor.Black, 4, 4, 10, true); //Flatten alpha channel thumbnail.Channels.RemoveAlpha(RgbColor.White); thumbnail.Save(@"Images\out.jpg"); } }