How can I convert a WriteableBitmap to stream on WP8 platform?
Final goal is to dump the image output produced by native code to the CameraRoll library using SavePictureToCameraRoll(filename, stream)
How can I convert a WriteableBitmap to stream on WP8 platform?
Final goal is to dump the image output produced by native code to the CameraRoll library using SavePictureToCameraRoll(filename, stream)
You can encode your bitmap to stream with WritableBitmap.SaveJpeg method and use this stream as a parameter to MediaLibrary.SavePictureToCameraRoll.
Note: before calling MediaLibrary.SavePictureToCameraRoll don't forget to set the stream position to 0 if you're using a MemoryStream. Like this:
var wb = new WriteableBitmap(bitmap);
var fileStream = new MemoryStream();
wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 100, 100);
fileStream.Seek(0, SeekOrigin.Begin);
var m = new MediaLibrary();
m.SavePictureToCameraRoll("test", fileStream);