Silverlight: converting WriteableBitmap to stream
-
14-09-2020 - |
Question
Given a WriteableBitmap, how can I save the bitmap back into an image stream (JPG or BMP)?
My scenario is:
- Show OpenFileDialog, let user select image
- Load image into WriteableBitmap
- Resize image
- Send image stream to web service
Step #4 is what I'm having trouble with. How can I go from WriteableBitmap -> Stream?
Solution
Ok, so Silverlight doesn't have anything built-in to turn a WriteableBitmap into an image stream.
After much wailing and gnashing of teeth, I found the excellent open source ImageTools library for Silverlight, which provides encoders and decoders for JPG, BMP, GIF, and PNG.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow