How to save BitmapImage / WriteableBitmap using SaveFileDialog in Silverlight 3.0?

后端 未结 2 828
难免孤独
难免孤独 2020-12-18 13:11

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

相关标签:
2条回答
  • 2020-12-18 13:31

    There are a several open-source encoders out there:

    FJCore: http://code.google.com/p/fjcore/

    Joe Stegman's PNG Encoder: http://blogs.msdn.com/jstegman/archive/2008/04/21/dynamic-image-generation-in-silverlight.aspx

    FreeImage: http://freeimage.sourceforge.net/

    You can use any of these to encode various formats. Here's a post on saving a WriteableBitmap once it's baked:

    http://community.irritatedvowel.com/blogs/pete_browns_blog/archive/2009/03/18/Silverlight-3-1320-The-Bitmap-API-2F00-WriteableBitmap.aspx

    UPDATE: After doing some more searching it looks like saving a WriteableBitmap to a file is limited in SL3 due to security issues. There is a workaround:

    http://geekswithblogs.net/braulio/archive/2009/07/12/export-canvas-to-png-and-save-it-in-your-local.aspx

    Looks like you have to save the contents of a Canvas to a file. You should be able to modify the sample to save JPEG or other formats.

    0 讨论(0)
  • 2020-12-18 13:43

    I have previously written this post that goes through how to save XAML to a bitmap using a writeable bitmap, the save dialog box and FJCore.

    http://blog.blueboxes.co.uk/2009/07/21/rendering-xaml-to-a-jpeg-using-silverlight-3/

    0 讨论(0)
提交回复
热议问题