2011-09-12 55 views
-2

我有个RGBA值的值, 的R - 255, ģ - 103, 乙 - 103, 阿尔法 - 103.需要计算的像素

需要的(RGB)色彩值的组合。示例 - 26532.(颜色值/像素值的组合)

说明 - 图像由像素组成,每个像素具有颜色组合(如 - RGB)。 需要计算图像的平均值,我们需要具有像素的唯一值。 每个像素有4个颜色值,但需要的像素值(色值的组合)

+0

如何将*你*计算出 “像素值”?你知道如何获得ARGB值吗? –

+0

你尝试了什么? – VMAtm

+0

http://en.wikipedia.org/wiki/RGBA_color_space –

回答

2

您可以使用BitConverter的RGBA字节转换为单个int值:

 byte[] components = new byte[4]; 
     components[0] = 103;  // blue 
     components[1] = 103;  // green 
     components[2] = 255;  // red 
     components[3] = 103;  // alpha 

     int pixelValue = BitConverter.ToInt32(components, 0); 
+0

我会试试这个.. – Yasar

0
int value = Color.FromArgb(103, 103, 255, 103).ToArgb() 
+0

我使用这段代码得到了结果。 int r = objcolor.R; int g = objcolor.G; int b = objcolor.B; int rgb =((r&0x0ff)<< 16)| ((g&0x0ff)<< 8)| ((b&0x0ff)) – Yasar