Skip to main content
Home Forums General Silverlight New Features in Silverlight 3 How to safe image through SaveFileDialog
2 replies. Latest Post by ksleung on March 30, 2009.
(0)
zeeshanu...
Member
2 points
4 Posts
03-30-2009 4:50 PM |
SaveFileDialog mySafeFileDialog = new SaveFileDialog(); bool? ok = mySafeFileDialog.ShowDialog();
{
fs.Write(info, 0, info.Length);
fs.Close();
}
Through this code we can safe text but how can I safe an image.
codeblock
Contributor
4060 points
716 Posts
03-30-2009 5:43 PM |
If you need to encode an image you have to write your code by yourself. There isn't any encoder in Silverlight.
HTH
ksleung
5366 points
1,028 Posts
03-30-2009 5:45 PM |
You cannot do that in SL3 beta for most images because you don't have access to the bitmap for security reason.
Even if you can do that, say if SL3 RTW supports it, or if the image was programmatically generated by you through the use of WriteableBitmap, you will still only have access to a bitmap, and you'd need to roll your own Jpg/Bmp/Png encoder. Encoding is easier than decoding, and you can probably find some open source C# Png encoder out there. The output of the encoder should be a Stream which is then piped to SaveFileDialog.
See this thread for some related discussions: http://silverlight.net/forums/t/82223.aspx
If this is important to you (as it is to me), please raise your concern and let the Silverlight team knows.