I save a a plot to a png file from my image. I use a code snippet I found on the net:
Rect bounds = LayoutInformation.GetLayoutSlot(SensorPanelGraph);
var bitmap = new RenderTargetBitmap((int)bounds.Width, (int)bounds.Height, 96, 96, PixelFormats.Pbgra32);
DrawingVisual dv = new DrawingVisual();
using (DrawingContext dc = dv.RenderOpen())
{
VisualBrush vb = new VisualBrush(SensorPanelGraph);
dc.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
}
bitmap.Render(dv);
string path = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + @"\Graph.png";
using (FileStream outStream = new FileStream(path, FileMode.Create))
{
PngBitmapEncoder enc = new PngBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(bitmap));
enc.Save(outStream);
}
What I would like to do now is to put a Legend on the upper right corner of my final image. I can use the same code to generate an image of my Legend on the GUI, but I have no clue how to overlay it in the upper right corner of my graph png.
Thanks in advance!