Typically on a website this would done with JavaScript and a canvas. They’re a lot of graphics libraries to start with. Just google for one that meets you requirements. you will to know some geometry. You draw a dotted line on splines that represent the curve of the outline. You may also need an edge detection code. If the outline is just a rectangle, then just draw a rectangle with dotted border.
How to draw an outline of a region in graphics in .net core?
Mariam_S
0
Reputation points
How to draw an outline around a Region that made by union and intersection between shapes like Rectangle and Ellipse. Note I wanna draw only the outline not fill the entire region with color.
public class ShapeVM
{
public List<Point> Points { get; set; }
}
public string DrawShapes(List<ShapeVM> shapes) {
var origBmp = new Bitmap(800, 700); Graphics g = Graphics.FromImage(origBmp);
g.Clear(Color.Transparent);
var firstshape = shapes.FirstOrDefault();
Region graphicsRegion = new Region(new Rectangle(firstshape.Points[0], new Size(firstshape.Points[1])));
shapes.Remove(firstshape);
foreach (var item in shapes)
{
if (item.ShapeType == ShapeTypeEnum.Rectangle)
{
Region rectangle = new Region(new Rectangle(item.Points[0], new Size(item.Points[1])));
graphicsRegion.Union(rectangle);
rectangle.Dispose();
}
else
{
Rectangle rectangle = new Rectangle(item.Points[0], new Size(item.Points[1]));
GraphicsPath ellipse = new GraphicsPath();
ellipse.AddEllipse(rectangle);
graphicsRegion.Exclude(ellipse);
ellipse.Dispose();
}
}
g.FillRegion(regionFillBrush, graphicsRegion);
graphicsRegion.Dispose();
MemoryStream ms = new MemoryStream();
origBmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
byte[] byteImage = ms.ToArray();
var imageString = $"data:image/png;base64,{Convert.ToBase64String(byteImage)}";
g.Dispose();
origBmp.Dispose();
return imageString; //"/Files" + fileName;
}