Saving image of a plot in Silverlight

Oystein Bjorke 10 ár síðan 0
This discussion was imported from CodePlex

Tech_Junkie wrote at 2012-08-03 10:50:

I'm trying to save my plot (lineseries with axes) to something that I can use elsewhere in my application without having to load an oxyplot element. For this I would like to export the plot to an image (preferable just a standard silverlight implementation for internal use).

What would be the best way to go about this?

 

Would it be possible to get a xaml path from the plot? as this is one of the easiest ways to store vector data in silverlight.


dcuccia wrote at 2012-08-03 21:24:

Not sure if there's a new way to do this, but in our OSS project (MIT/X-11 license) we want to persist images of controls, with the additional option of printing.

Here's how we do that bit:

In Silverlight, WritableBitmap has a constructor overload that takes any UIElement, so you can...
1) create a WriteableBitmap using the UIElement overload
2) encode the bitmap to a .jpg (optional)
3) save the image
    a) if you want a user-specified location to save, you have to use an OpenFileDialog
    b) otherwise, you can save to isolated storage


Tech_Junkie wrote at 2012-08-06 16:33:

This looks good! Thank you! I think this will be very sufficient for my needs.


dcuccia wrote at 2012-08-06 19:46:

Good to hear - my pleasure. :)


objo wrote at 2012-08-09 00:19:

Isn't this the same as issue http://oxyplot.codeplex.com/workitem/9626?

I will look at your solution later, thanks for sharing!