字节数组Windows Phone 8.1中的像素数据

时间:2016-01-05 12:51:54

标签: c# windows-phone-8.1

我正在尝试从byte数组中提取像素数据。我正在使用这种方法。

MemoryStream memoryStream = new MemoryStream(imagearray);
using (IRandomAccessStream randomAccessStream = memoryStream.AsRandomAccessStream())
{
    BitmapTransform transform = new BitmapTransform()
    {
         //these is original width and height 
         ScaledWidth = Convert.ToUInt32(width),
         ScaledHeight = Convert.ToUInt32(height)
    };
    decoder = await BitmapDecoder.CreateAsync(randomAccessStream);
    PixelDataProvider provider = await decoder.GetPixelDataAsync(decoder.BitmapPixelFormat,decoder.BitmapAlphaMode, transform, ExifOrientationMode.IgnoreExifOrientation, ColorManagementMode.DoNotColorManage);
    byte[] pixels = provider.DetachPixelData();
 }

pixels数组的每个第4个索引都被255覆盖,类似于{25,12,128,255(original value was 122),32,149,212,255(original value was 122),.....}(我知道原始值,因为原始图像是由应用程序生成的)。

我试图通过以下方式做到这一点但结果相同。

var pixelStream = writableimage.PixelBuffer.AsStream();
var pixels2 = new byte[pixelStream.Length];
await pixelStream.ReadAsync(pixels2, 0, pixels2.Length);

这些更改对图像的外观没有影响,但我的应用程序无法容忍此类更改。

0 个答案:

没有答案