转换的BitmapImage以字节的Windows

转换的BitmapImage以字节的Windows

本文介绍了转换的BitmapImage以字节的Windows Phone 8.1运行时[]数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

有几样要做到这一点,但他们对于Windows Phone的8.0或8.1的Silverlight。

There are a few samples to do this but they are for Windows Phone 8.0 or 8.1 Silverlight.

但你怎么能对Windows Phone的8.1运行时做到这一点?

But how can you do this for Windows Phone 8.1 Runtime?

推荐答案

您不能从Windows.UI.Xaml.Media.Imaging提取像素的并几乎可以互换使用。该属性:

The most general solution is to use a WriteableBitmap instead of a BitmapImage. These classes are both BitmapSources and can be used almost interchangeably. The WriteableBitmap provides access to its pixel data via its PixelBuffer property:

byte[] pixelArray = myWriteableBitmap.PixelBuffer.ToArray(); // convert to Array
Stream pixelStream = wb.PixelBuffer.AsStream();  // convert to stream



否则,你将需要获得来自任何地方的BitmapImage的距离得到了他们的像素。根据BitmapImage的初始化方式您可以从它的财产。该拥有的从基于其UriSource一个BitmapImage的创建WriteableBitmap的。

Otherwise you will need to acquire the pixels from wherever the BitmapImage got them from. Depending on how the BitmapImage was initialized you may be able to find its origin from its UriSource property. The WinRT Xaml Toolkit has an extension method FromBitmapImage to create a WriteableBitmap from an BitmapImage based on its UriSource.

这是丑陋的办法是使BitmapImage的成图像,创建的基于图像,然后获取其像素RenderTargetBitmap的()

An ugly option would be to render the BitmapImage into an Image, create a RenderTargetBitmap based on the Image and then get its Pixels with RenderTargetBitmap.CopyPixelsAsync()

这篇关于转换的BitmapImage以字节的Windows Phone 8.1运行时[]数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 01:24