Skip to main content

Microsoft Silverlight

Answered Question How to safe image through SaveFileDialogRSS Feed

(0)

zeeshanullah
zeeshanu...

Member

Member

2 points

4 Posts

How to safe image through SaveFileDialog

SaveFileDialog mySafeFileDialog = new SaveFileDialog();

bool? ok = mySafeFileDialog.ShowDialog();

if (ok == true)

{

Stream fs = (Stream)mySafeFileDialog.OpenFile();byte[] info = (new UTF8Encoding(true)).GetBytes(txt.Text);

fs.Write(info, 0, info.Length);

fs.Close();

}

 

Through this code we can safe text but how can I safe an image.

codeblock
codeblock

Contributor

Contributor

4060 points

716 Posts

Silverlight MVP
Answered Question

Re: How to safe image through SaveFileDialog

If you need to encode an image you have to write your code by yourself. There isn't any encoder in Silverlight.

HTH

If this answers your question, please "mark it as answer"

--
Andrea Boschin
MVP Silverlight & Silverlight Insider
, Me on Twitter

ksleung
ksleung

Contributor

Contributor

5366 points

1,028 Posts

Answered Question

Re: How to safe image through SaveFileDialog

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.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities