微信wp的图片分享,怎样调用当前存入图片库mediaLibrary的图片?
wp8怎样调用当前存入图片库mediaLibrary的图片?c#
我们现在有这样一个刚截取的图片。
c#
var fileName = "hello";
WriteableBitmap aaa = new WriteableBitmap(555, 555);
aaa.Render(ccc, new MatrixTransform());
aaa.Invalidate();
SaveToMediaLibrary(aaa, fileName, 100);
如果提取文件路径,把pics 代入到path中,应该怎么写?
C#
MediaLibrary mediaLibrary = new MediaLibrary();
PictureAlbumCollection albums = mediaLibrary.RootPictureAlbum.Albums;
var pics = albums[0].Pictures[albums[0].Pictures.Count - 1].GetImage();
var pic = albums[0].Pictures[albums[0].Pictures.Count - 1].GetThumbnail();
又怎样调取thumbnail的地址呢?
C#
byte[] PNG = gogo(pics);
byte[] PNGS = gogo(pics);
message.ThumbData = PNG;
message.ImageData = PNGS;
}
这个byte转化工具是不是很鸡肋?我们一定要提取path么?能够直接调用writeablebitmap中的图片么?
c#
private byte[] gogo(string path)
{
StreamResourceInfo info = App.GetResourceStream(new Uri(path, UriKind.Relative));
if (info == null) return null;
Stream stream = info.Stream;
byte[] data = new byte[stream.Length];
stream.Read(data, 0, (int)stream.Length);
return data;
}