【发布时间】:2012-07-20 14:59:48
【问题描述】:
我可以使用以下代码从资源 JPG 图像文件轻松创建 BitmapImage...
Windows::Foundation::Uri^ uri = ref new Windows::Foundation::Uri(L"ms-appx:///Hippo.JPG");
Imaging::BitmapImage^ image = ref new Imaging::BitmapImage(uri);
但是 WritableBitmap 不接受 Uri。我看到了一个 SetSource 方法,但它需要一个 IRandomaccessStream 而不是 Uri。而且我不知道如何从 JPG 文件创建一个。我一遍又一遍地在网上搜索,但找不到一个直截了当的答案。任何帮助将不胜感激。
我想要这样的东西......
Windows::UI::Xaml::Media::Imaging::WriteableBitmap image = ref new Windows::UI::Xaml::Media::Imaging::WriteableBitmap();
image->SetSource(somehowGetRandomAccessStreamFromUri);
但是,如何从 uri 中获取 IRandomaccessStream 实例?我今天才开始开发 C++ Metro 应用程序,所以可能是错误的,但我发现它过于复杂,因为洋葱皮太多。
【问题讨论】:
标签: windows-8 windows-runtime winrt-xaml c++-cx imaging