User187056398 posted
Something like this?
Bitmap MyBitmap = new Bitmap(MapPath(@"~\Images\April.jpg"));
Rectangle Rect = new Rectangle(0, 0, MyBitmap.Width, MyBitmap.Height);
BitmapData BmpData = MyBitmap.LockBits(Rect,
ImageLockMode.ReadOnly,
MyBitmap.PixelFormat);
int Size = BmpData.Stride * MyBitmap.Height;
byte[] RGBs = new byte[Size];
IntPtr Pointer = BmpData.Scan0;
System.Runtime.InteropServices.Marshal.Copy(Pointer, RGBs, 0, Size);
MyBitmap.UnlockBits(BmpData);
// we've got all the RGB values in an array
int Sum = 0;
for (int Index = 0; Index < RGBs.Length; Index++)
Sum += RGBs[Index];
// higher Average means a lighter picture (255 = white, 0 = black)
int Average = Sum / RGBs.Length;