private void SaveAsPicture_Click(object sender, RoutedEventArgs e)
{
WriteableBitmap bmp = new WriteableBitmap(MyUIElement, null);
var library = new MediaLibrary();
MemoryStream stream = new MemoryStream();
bmp.SaveJpeg(stream, 100, 100, 0, 90);
library.SavePicture("Certificate", stream);
}
This should save the rendering of the MyUIElement to a bmp then save that as a Jpeg in the medialibrary but i’m getting a value does not fall within expected range error on the line with library.SavePicture("Certificate", stream);
Any ideas?
I got the same error like the one you had. And I solved it by following the example on How to: Encode a JPEG for Windows Phone and Save to the Pictures Library on MSDN.
So your method should look as following