I want to draw a rectangle over the top of an image, how do i go about this?5KBVj.png (174.5 KB)
I have observed your requirements and request you to please try using following sample code on your end.
private static void AddRectToJpg()
{
String path = @"C:\Imaging Data\image\";
var file = path + "MediumBO17P072102";
//var file = "MediumBO17P072102";
using (var image = Aspose.Imaging.Image.Load(file + ".jpg"))
{
Graphics graphic = new Graphics(image);
// graphic.Clear(Color.Yellow);
graphic.DrawRectangle(new Pen(Color.Red), new Rectangle(30, 10, 40, 80));
//graphic.DrawRectangle(new Pen(new SolidBrush(Color.Blue)), new Rectangle(10, 30, 80, 40));
using (var stream = new MemoryStream())
{
image.Save(stream, new Aspose.Imaging.ImageOptions.PngOptions());
File.WriteAllBytes(file + "_2.png", stream.ToArray());
}
}
}