BCH.BCHTool.getColorCount C# (CSharp) Method

getColorCount() private method

private getColorCount ( Bitmap img ) : int
img System.Drawing.Bitmap
return int
        private int getColorCount(Bitmap img)
        {
            Color[] colors = new Color[img.Width * img.Height];
            int colorct = 1;

            for (int i = 0; i < colors.Length; i++)
            {
                Color c = img.GetPixel(i % img.Width, i / img.Width);
                int index = Array.IndexOf(colors, c);
                if (c.A == 0) index = 0;
                if (index < 0)
                {
                    colors[colorct] = c;
                    colorct++;
                }
            }
            return colorct;
        }