2015-10-19 51 views
3

我需要将Stream转换为IRandomAccessStream(以创建BitmapDecoder)。我试图在BitmapDecoder中投射和搜索内置方法,但找不到任何内容。将流转换为IRandomAccessStream

那么我该怎么做?

+0

你可以显示你有什么代码或已经尝试过..这不应该是那么困难,但它会很高兴看到你写的代码明智,看看你出错的地方 – MethodMan

+1

可能的重复[有没有办法将System.IO.Stream转换为Windows.Storage.Streams.IRandomAccessStream?](http://stackoverflow.com/questions/7669311/is-there-a-way-to-convert-a-system-io- stream-to-a-windows-storage-streams-irando) – MethodMan

回答

11

有对于一个扩展方法:

Stream stream = GetSomeStream(); 
IRandomAccessStream randomAccessStream = stream.AsRandomAccessStream(); 

只要确保你在你的代码文件的顶部有using System.IO

+0

完美。 (现在还不能接受。)我不能相信在搜索Intellisense时我没有看到! – ispiro

+0

Yippie-ki-yeah !!找不到任何地方。谢谢 – raddevus