Save as png

Oystein Bjorke 5 years ago 0
This discussion was imported from CodePlex

sanndeb wrote at 2011-11-23 05:51:

if you want to use save as png use the following

// todo: Use imagetools.codeplex.com
using ImageTools;
using ImageTools.IO;
using ImageTools.IO.Png;

public partial class Plot : Control, IPlotControl
{
//..............................
        public void SaveAsPng(SaveFileDialog dialog)
        {
            SaveToImage(dialog, new PngEncoder());
        }
 
 
        void SaveToImage(SaveFileDialog dialog, IImageEncoder encoder)
        {
            using (var stream = dialog.OpenFile())
            {
                var image = this.ToImage();
                encoder.Encode(image, stream);
            }
        }
//..............................
}
Similerly you can save as bmp etc as well....

objo wrote at 2011-11-23 06:40:

Yes, Imagetools seems to be a great solution for png export for Silverlight.

I will add an example showing how to use it, but don't think the reference should be added in the standard OxyPlot.Silverlight project.

CodePlex