-3

I have a RGBA values, R - 255, G - 103, B - 103, Alpha - 103.

Need combination of the (RGB) color value. Example - 26532.(combination of colour value/Pixel value)

Description - Image is made of pixels, each pixel has combination of colors(like - RGB). Need to calculate the mean of the image and we need to have the unique value of the pixel. Each pixel has 4 colour values but need the pixel value( combination of colour values)

VMAtm
  • 27,943
  • 17
  • 79
  • 125
Yasar
  • 1

3 Answers3

2

You can use BitConverter to convert the RGBA bytes to a single int value:

        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);
ColinE
  • 68,894
  • 15
  • 164
  • 232
0

You should be able to do a loop through every pixel, and calculate the pixel value on the fly if you know the pixel color values.

Relevant questions:

How can I iterate through each pixel in a .gif image in C#?

How to calculate the average rgb color values of a bitmap

Community
  • 1
  • 1
Sprunth
  • 725
  • 6
  • 10
0
int value = Color.FromArgb(103, 103, 255, 103).ToArgb()
Felix C
  • 1,755
  • 5
  • 26
  • 40
  • i got the result using this code. int r = objcolor.R; int g = objcolor.G; int b = objcolor.B; int rgb = ((r & 0x0ff) << 16) | ((g & 0x0ff) << 8) | ((b & 0x0ff)) – Yasar Sep 12 '11 at 13:39