In my C# (3.5) application I need to get the average color values for the red, green and blue channels of a bitmap. Preferably without using an external library. Can this be done? If so, how? Thanks in advance.
Trying to make things a little more precise: Each pixel in the bitmap has a certain RGB color value. I'd like to get the average RGB values for all pixels in the image.
Best Solution
The fastest way is by using unsafe code:
Beware: I didn't test this code... (I may have cut some corners)
This code also asssumes a 32 bit image. For 24-bit images. Change the x*4 to x*3