Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

wpf export graph to image problem

Solved!
Go to solution

My problem is I have created a new custom custom using the NI wpf graph as the basis. The control consist mainly of the graph,its axes and legends on a grid. To allow the legend to be moved around, I put it in a child grid. My problem is while trying to export the control as an image I am using the code below (similar to wpf graph export to image😞

 

Rect bounds = LayoutInformation.GetLayoutSlot(MainGrid);
var bitmap = new RenderTargetBitmap((int)bounds.Width + 1, (int)bounds.Height + 1, 96, 96, PixelFormats.Default);
bitmap.Render(MainGrid);

 

My problem is the axes and the edges of the image exported to clipboard is dark as shown below. Is saved to image, the edges are instead transparent but better (not visible in the photos app but visible in paint). My question is why is this behavior and how can it be avoided?

 

Thanks.

tester2.png

0 Kudos
Message 1 of 3
(4,595 Views)

I did a bit of research and it seems the dark color is due to the trasnparency of the axes and edges of the image: the clipboard in windows does not support transparent image. The question is how can this transparency be removed from the axes and edges of the image?

 

Thanks.

0 Kudos
Message 2 of 3
(4,590 Views)
Solution
Accepted by topic author falopsy

The problem is the default color of grid or niGraph in WPF is transparent. I simply changed either color and the image now saved properly. 

0 Kudos
Message 3 of 3
(4,585 Views)