Question

i have a XAML canvas element and i need to save the canvas element and whatever in it to any image format(JPEG,PNG) with high quality, How to do that in silverlight using c#.i saw the Fjcore code but i dont get what it is doing , please explain with a code and please comment what it is doing.

Was it helpful?

Solution

You can try Imagetools for Silverlight library in Codeplex. Here is an example on saving a canvas element to JPEG image :

//Convert UIElement to Image
ei = ImageExtensions.ToImage(myCanvas);

//Save the image
SaveFileDialog saveDlg = new SaveFileDialog();
saveDlg.Filter = "JPEG Files (*.jpeg)|*.jpeg";
saveDlg.DefaultExt = ".jpeg";
if ((bool)saveDlg.ShowDialog())
{
    using (Stream fs = saveDlg.OpenFile())
    {
        ei.WriteToStream(fs);
    }
}

Further information on how to use it can be found in the link above, and as I see it, looked very simple.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top