转换一个IBuffer要在Windows Phone 8.1的字节数组,怎么样? [英] Convert an IBuffer to a byte array in Windows Phone 8.1, how?

查看:136
本文介绍了转换一个IBuffer要在Windows Phone 8.1的字节数组,怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写的Windows Phone 8.1的应用程序。

I'm writing an application for Windows Phone 8.1.

我需要一个的UIElement保存为图像文件(我更喜欢JPG或PNG)。
我使用RenderTargetBitmap类来做到这一点。
调用方法RenderAsync我的UIElement后,我创建一个包含方法GetPixelsAsync的)我RenderTargetBitmap的结果(一IBuffer。

I need to save an UIElement as an image file (I'd prefer JPG or PNG). I'm using RenderTargetBitmap class to do this. After calling the method RenderAsync on my UIElement I create an IBuffer that contains the result of the method GetPixelsAsync() of my RenderTargetBitmap.

现在我需要调用该方法ToArray()我IBuffer转换成字节数组使用类似的BitmapEncoder救我的形象,但似乎在Windows Phone 8.1也没有对任何IBuffer toArray()方法,而在Windows 8.1是否存在。

Now I need to call the method ToArray() to convert my IBuffer in a byte array to save my image using something like BitmapEncoder, but it seems that on Windows Phone 8.1 there isn't any ToArray() method for IBuffer, while on Windows 8.1 is present.

我怎样才能解决这个问题呢?

How can I solve this issue?

感谢您!

推荐答案

这是可在Windows Phone 8.1,但它的可用的WP 8.0。
(见 MSDN链接

This is available on Windows Phone 8.1, but it not available on WP 8.0. (see MSDN link)

您需要确保你有适当的名称空间但因此它是由编译器发现:

You need to make sure that you include the appropriate namespace however so it is found by the compiler:

使用System.Runtime.InteropServices.WindowsRuntime

这篇关于转换一个IBuffer要在Windows Phone 8.1的字节数组,怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆