using System.Drawing;
namespace DelftTools.Utils.Drawing
{
public static class ImageExtensions
{
///
/// Draws on top of at the provided x and y offset
///
/// Original image
/// Overlay image
/// X offset for overlay drawing
/// Y offset for overlay drawing
public static Image AddOverlayImage(this Image originalImage, Image overlayImage, int xOffSet, int yOffSet)
{
var image = (Image) originalImage.Clone();
using (var gfx = Graphics.FromImage(image))
{
gfx.DrawImage(overlayImage, new Point(xOffSet, yOffSet));
}
return image;
}
///
/// Draws on top of at the provided x and y offset
/// and scales down/up to the provided and
///
/// Original image
/// Overlay image
/// X offset for overlay drawing
/// Y offset for overlay drawing
/// Width for
/// /// Height for
public static T AddOverlayImage(this T originalImage, Image overlayImage, int xOffSet, int yOffSet, int width, int height) where T : Image
{
var image = (T) originalImage.Clone();
using (var gfx = Graphics.FromImage(image))
{
gfx.DrawImage(overlayImage, new Rectangle(new Point(xOffSet, yOffSet), new Size(width, height)));
}
return image;
}
}
}