2 dancingyomin dancingyomin 于 2014.07.26 13:00 提问

wp8怎样调用当前存入图片库mediaLibrary的图片?c#

wp8怎样调用当前存入图片库mediaLibrary的图片?c#

1.能够直接调用writeablebitmap中的图片么?
2.如果必须使用文件路径,把pics 代入到path中,应该怎么写?现在的类型貌似是不对应的?

{ 
     WriteableBitmap aaa = new WriteableBitmap(555, 555);
     aaa.Render(cc, new MatrixTransform());
     aaa.Invalidate();
     SaveToMediaLibrary(aaa, fileName, 100);

     MediaLibrary mediaLibrary = new MediaLibrary();
     PictureAlbumCollection albums = mediaLibrary.RootPictureAlbum.Albums;
     var pics  = albums[0].Pictures[albums[0].Pictures.Count - 1].GetImage();
     byte[] png = gogo(pics);  
}

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;
}

1个回答

lindexi_gd
lindexi_gd   2015.07.28 16:17
 private async void SelectImageOne(byte[]outArary)
 {
            StorageFile storageFile=await Windows.Storage.KnownFolders.DocumentsLibrary.CreateFileAsync("1.txt",Windows.Storage.CreationCollisionOption.ReplaceExisting);
            awaitFileIO.WriteBytesAsync(storageFile, outArary);
 }

可以读文件,用他读图片,我想到的

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!