Save as png

Nov 23, 2011 at 4:51 AM

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....
Coordinator
Nov 23, 2011 at 5:40 AM

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.