Bloom.Edit.JpegWarningDialog.GetPercentWhiteOfLine C# (CSharp) Method

GetPercentWhiteOfLine() private static method

private static GetPercentWhiteOfLine ( Bitmap bmp, int lineNumber ) : double
bmp System.Drawing.Bitmap
lineNumber int
return double
        private static double GetPercentWhiteOfLine(Bitmap bmp, int lineNumber)
        {
            if(lineNumber >= bmp.Height)
                return 0; //guard against math errors by the caller

            const int maxCombinedRgbValueToBeConsideredWhite = 3 * 253; // true white is 255. We'll count off-white as well
            int whiteCount=0;
            for (int x = 0; x < bmp.Width; x++)
            {
                var pixelColor = bmp.GetPixel(x, lineNumber);
                //we'll add up the R, G, and B
                if ((pixelColor.R + pixelColor.G + pixelColor.B) > maxCombinedRgbValueToBeConsideredWhite)
                    ++whiteCount;
            }
            return ((double)whiteCount)/(double)bmp.Width;
        }