Farukh
Farukh

Reputation: 302

Save Chart as an image on Hard Drive

I am looking for ways to save the output of a Chart control as an image on the hard drive. Is it possible in SL? as I am not sure so thought of putting a question here..

Thanks...

Upvotes: 0

Views: 836

Answers (1)

TerenceJackson
TerenceJackson

Reputation: 1786

have a look here: Can I programmatically capture snapshot of a Silverlight User Control?

You can simply take a screenshot of your chart. If you want to put in on the HD with silverlight you need to open a SaveFileDialog. Then it is possible.

EDIT: If you want to save it in different formats use ImageTools. http://imagetools.codeplex.com/. If you use ImageTools you can get a stream like this:

var editBitmap = new WriteableBitmap(1024, 786);
            editBitmap = new WriteableBitmap((int)(this.RenderSize.Width), (int)(this.RenderSize.Height));
            editBitmap.Render(this, new MatrixTransform());
            editBitmap.Invalidate();

            var myImage = editBitmap.ToImage();
            Stream stream = myImage.ToStreamByExtension("png");

Hope this helps.

BR,

TJ

Upvotes: 3

Related Questions