954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Save canvas in silverlight

I need to save a video as an image in silverlight, for my new webpage functionality, at http://www.game4tress.com/ecardsender.aspx . Now, this would be easy in WPF, but seems that silverlight can't access the RenderTargetBitmap and BitmapEncoder. I was able to discover that RenderTargetBitmap can be replaced with WriteableBitmap, but i can't replace BitmapEncoder.
If the function was made in WPF, i would use this code:

myCanvas.HorizontalAlignment=HorizontalAlignment.Stretch;

int Height=(int)myCanvas.ActualHeight;
int Width=(int)myCanvas.ActualWidth;

RenderTargetBitmap bmp=new RenderTargetBitmap(Width,Height,96,96,PixelFormats.Pbgra32);

bmp.Render(myCanvas);
BitmapEncoder encoder=new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));

using(System.IO.Stream stm=System.IO.File.Create("C:\\Temp.jpeg"))
{
   encoder.Save(stm);
   stm.Dispose();
}

I can't seem able to find an equivalent way out in Silverlight. Can you, please help?
My thanks in advanced

game4tress
Newbie Poster
16 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: