【发布时间】:2014-08-05 14:28:28
【问题描述】:
我有一个大小为 160x175 像素的图像。我使用以下代码将其加载到字节数组中:
var file = await StorageFile.GetFileFromApplicationUriAsync(
new Uri("ms-appx:///Assets/Image.png"));
using (var stream = await file.OpenAsync(FileAccessMode.Read))
{
var decoder = await BitmapDecoder.CreateAsync(stream);
var myTransform = new BitmapTransform
{
ScaledHeight = (uint)pixelHeight,
ScaledWidth = (uint)pixelWidth
};
var pixels = await decoder.GetPixelDataAsync(
BitmapPixelFormat.Rgba8,
BitmapAlphaMode.Straight,
myTransform,
ExifOrientationMode.IgnoreExifOrientation,
ColorManagementMode.DoNotColorManage);
var bytes = pixels.DetachPixelData();
}
现在我想检查每个像素是否透明。我的字节数组的长度为 112000。我认为是 160px * 175px * 4 (RGBA)。那么如果字节数组中的每4个字节就是像素的透明度字节,当它的内容为255的时候就是透明度是对的吗?
以及像素在字节数组中是如何排序的?水平还是垂直?
我在 MSDN 中找不到任何关于带像素的字节数组的外观。
【问题讨论】:
-
A=255 是不透明的,A=0 是透明的。
-
谢谢。这有帮助:)
标签: c# bytearray transparency pixel