如何分解整数数组为一个字节数组(像素的编码) [英] how to decompose integer array to a byte array (pixel codings)
本文介绍了如何分解整数数组为一个字节数组(像素的编码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
喜对不起,通过改写我的问题是恼人的,但我只是发现我的答案的地步。
我 INT
阵列RGB值组成的,我需要分解的 INT
数组转换成字节阵列,但应在BGR顺序
RGB值组成的整型数组被创建,像这样:
PIX [指数++] =(255<< 24)| (红色<< 16)|蓝色;
解决方案
C#code
//转换成整数数组重新presenting [ARGB]值的字节数组重新presenting [BGR]值
私人字节[] convertArray(INT []数组)
{
字节[] = newarray新的字节[array.Length * 3];
的for(int i = 0; I< array.Length;我++)
{
newarray [我* 3 =(字节)阵列[我]
newarray [我* 3 + 1] =(字节)(数组[我] >> 8);
newarray [I * 3 + 2] =(字节)(数组[I] >> 16);
}
返回newarray;
}
Hi sorry for being annoying by rephrasing my question but I am just on the point of discovering my answer.
I have an array of int
composed of RGB values, I need to decompose that int
array into a byte array, but it should be in BGR order.
The array of int composed of RGB values is being created like so:
pix[index++] = (255 << 24) | (red << 16) | blue;
解决方案
C# code
// convert integer array representing [argb] values to byte array representing [bgr] values
private byte[] convertArray(int[] array)
{
byte[] newarray = new byte[array.Length * 3];
for (int i = 0; i < array.Length; i++)
{
newarray[i * 3] = (byte)array[i];
newarray[i * 3 + 1] = (byte)(array[i] >> 8);
newarray[i * 3 + 2] = (byte)(array[i] >> 16);
}
return newarray;
}
这篇关于如何分解整数数组为一个字节数组(像素的编码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文