MediaLibrary.SavePicture以降低的分辨率保存图片流

时间:2012-12-21 15:06:18

标签: c# silverlight windows-phone-7 stream cameracapturetask

我构建了一个应用程序,允许用户捕获图像,然后将其保存到隔离存储和手机的媒体库中。

当我将这两张图片下载到我的电脑上时,我发现保存在独立存储器中的图片分辨率为2592x1944像素和262 dpi,而保存在媒体库中的图片则为1222x1630和72 dpi。我无法解释为什么会发生这种情况。我的相关代码隐藏是:

//Save image to isolated storage
Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);

//Save image to Media Library
MediaLibrary medialibrary = new MediaLibrary();
medialibrary.SavePicture(imageName, e.ChosenPhoto;);

(wb是从e.ChosenPhoto创建的WritableBitmap)

1 个答案:

答案 0 :(得分:0)

我认为它与从ChosenPhoto而不是WriteableBitmap保存它有关。尝试将图片保存到媒体库from Isolated Storage instead like this

// Encode WriteableBitmap object to a JPEG stream.
Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
fileStream.Close();

// Create a new stream from isolated storage, and save the JPEG file to the media library on Windows Phone.
fileStream = store.OpenFile(tempJPEG, FileMode.Open, FileAccess.Read);

MediaLibrary mediaLibrary = new MediaLibrary();
Picture pic = mediaLibrary.SavePicture("savedflimage.jpg", fileStream);
fileStream.Close();