我正在保存像这样的图像
BitmapImage img = (BitmapImage)Bild.Source;
WriteableBitmap wb = new WriteableBitmap(img);
String tempJPEG = "TempJPEG.jpg";
var myStore = IsolatedStorageFile.GetUserStoreForApplication();
if (myStore.FileExists(tempJPEG))
{
myStore.DeleteFile(tempJPEG);
}
IsolatedStorageFileStream myFileStream = myStore.CreateFile(tempJPEG);
Extensions.SaveJpeg(wb, myFileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
myFileStream.Close();
myFileStream = myStore.OpenFile(tempJPEG, FileMode.Open, FileAccess.Read);
String picname = "";
picname += DateTime.Now.Ticks.ToString();
picname += ".jpg";
MediaLibrary library = new MediaLibrary();
Picture pic = library.SavePicture(picname, myFileStream);
BitmapImage bm = new BitmapImage();
MessageBox.Show("Images successfully saved!");
现在我试图加载我从此功能中保存的所有图像,它们存储在照片库中的“已保存的图片”中。 到目前为止我得到了这段代码
using (var library = new MediaLibrary())
{
PictureAlbumCollection allAlbums = library.RootPictureAlbum.Albums;
PictureAlbum cameraRoll = allAlbums.Where(album => album.Name == "Saved Pictures").FirstOrDefault();
var CameraRollPictures = cameraRoll.Pictures;
}
但是cameraRoll每次都变为Null。
那么我应该如何将图片加载到我的应用程序中呢?
答案 0 :(得分:1)
这是给你的一个例子: (我已经过测试,效果非常好。)
http://blogs.msdn.com/b/johnalioto/archive/2011/01/28/10121728.aspx
另一件事,确保您添加访问照片库的功能:
<!-- For accessing photos in the media library. -->
<Capability Name="ID_CAP_MEDIALIB_PHOTO" />
希望它有所帮助。