Output color by R G B value for a Bitmap

image_pdfimage_print
   
 
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;

public class Analyzer {
    public static void Main() {
        Image sample = new Bitmap("a.jpg");
        MemoryStream buf = new MemoryStream();
        sample.Save(buf, ImageFormat.Bmp);
        byte[] currentImage = buf.GetBuffer();
        
        int[] stats = new int[3];
        for (int i = 0; i < currentImage.Length; ){
            for (int j = 0; j < 3; j++) {
                stats&#91;j&#93; += currentImage&#91;i&#93;;
                ++i;
            }
        }    
        Console.WriteLine("Blue: " + stats&#91;0&#93;);
        Console.WriteLine("Green: " + stats&#91;1&#93;);
        Console.WriteLine("Red: " + stats&#91;2&#93;);
        if ((stats&#91;0&#93; > stats[1]) &amp;&amp; (stats[0] > stats[2]))
            Console.WriteLine("This is a cold picture.");
        if ((stats[1] > stats[0]) &amp;&amp; (stats[1] > stats[2]))
            Console.WriteLine("This is a summer picture.");
        if ((stats[2] > stats[0]) &amp;&amp; (stats[2] > stats[1]))
            Console.WriteLine("This is a fiery picture.");
    }
}