Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to save BitmapImage / WriteableBitmap using SaveFileDialog in Silverlight 3.0?
    text
    copied!<p>How can a WriteableBitmap from Silverlight be Saved onto the File System, I am unsure what to do with the FileStream to make this work, it can be in Bitmap, PNG, Jpeg format etc, as long as a commercial library is not required.<br> Is it possible to do this?</p> <p>Here is my call to SaveDialog, below:</p> <pre><code> Dim SaveDialog As New SaveFileDialog If SaveDialog.ShowDialog Then Try Using FileStream As Stream = SaveDialog.OpenFile ' Save Image File Code Here End Using Catch ex As Exception End Try End If </code></pre> <p><strong>Edit</strong></p> <p>Added mention of WritableBitmap as this is what my XAML is writing to, I just need to save it, there is a WriteableBitmap.Pixels property which is a 1-dimensional array of integer pixels, can this be put into a filestream, and if so, how?</p> <hr> <p>Here is some example code I have that writes the Pixel Stream to a File, however this works it does not "bitmapify" the data and the resulting output is useless but it is writing my image stream, I just need to know how to mark-it-up so that it is a Bitmap file (or anything else). I have found the JPEG and PNG examples before, but none of them explain well how they work, I may have to use the PNGEncoding method as this is the only one that will integrate into my codebase. But is there a simple BMP file version out there?</p> <pre><code> Dim Image As Imaging.WriteableBitmap = _Style.Image Dim Area As Integer = Image.PixelWidth * Image.PixelHeight For Raster As Integer = 0 To Area - 1 Dim Pixel As Integer = Image.Pixels(Raster) Dim Bytes() = BitConverter.GetBytes(Pixel And &amp;HFF) FileStream.Write(Bytes, 0, 4) Next </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload