有有不白 2014-07-26 05:00 采纳率: 0%
浏览 1767

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 领域专家: 后端开发技术领域 2015-07-28 08: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);
     }
    

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

    评论

报告相同问题?