Ejemplo n.º 1
0
        static public Bitmap ProportionMask(Bitmap original, Color sample, double accuracy)
        {
            ProportionRGB       proportion = new ProportionRGB(sample);
            Func <Color, Color> func       =
                col => new ProportionRGB(col).ApproximatelyEqualTo(proportion, accuracy) ?
                Color.White : Color.Black;

            return(ProcessPixels(original, func));
        }
Ejemplo n.º 2
0
        public bool ApproximatelyEqualTo(ProportionRGB other, double accuracy)
        {
            if (this.ProportionR < other.ProportionR - accuracy || this.ProportionR > other.ProportionR + accuracy)
            {
                return(false);
            }
            if (this.ProportionG < other.ProportionG - accuracy || this.ProportionG > other.ProportionG + accuracy)
            {
                return(false);
            }
            if (this.ProportionB < other.ProportionB - accuracy || this.ProportionB > other.ProportionB + accuracy)
            {
                return(false);
            }

            return(true);
        }