Esempio n. 1
0
            public override ColorBgra Apply(ColorBgra color)
            {
                //adjust saturation
                byte intensity = color.GetIntensityByte();

                color.R = PixelUtils.ClampToByte((intensity * 1024 + (color.R - intensity) * satFactor) >> 10);
                color.G = PixelUtils.ClampToByte((intensity * 1024 + (color.G - intensity) * satFactor) >> 10);
                color.B = PixelUtils.ClampToByte((intensity * 1024 + (color.B - intensity) * satFactor) >> 10);

                HsvColor hsvColor = HsvColor.FromColor(color.ToColor());
                int      hue      = hsvColor.Hue;

                hue += hueDelta;

                while (hue < 0)
                {
                    hue += 360;
                }

                while (hue > 360)
                {
                    hue -= 360;
                }

                hsvColor.Hue = hue;

                ColorBgra newColor = ColorBgra.FromColor(hsvColor.ToColor());

                newColor   = blendOp.Apply(newColor);
                newColor.A = color.A;

                return(newColor);
            }
Esempio n. 2
0
 public Level()
     : this(ColorBgra.FromColor(Color.Black),
            ColorBgra.FromColor(Color.White),
            new float[] { 1, 1, 1 },
            ColorBgra.FromColor(Color.Black),
            ColorBgra.FromColor(Color.White))
 {
 }
Esempio n. 3
0
            public static Level AutoFromLoMdHi(ColorBgra lo, ColorBgra md, ColorBgra hi)
            {
                float[] gamma = new float[3];

                for (int i = 0; i < 3; i++)
                {
                    if (lo[i] < md[i] && md[i] < hi[i])
                    {
                        gamma[i] = (float)PixelUtils.Clamp(Math.Log(0.5, (float)(md[i] - lo[i]) / (float)(hi[i] - lo[i])), 0.1, 10.0);
                    }
                    else
                    {
                        gamma[i] = 1.0f;
                    }
                }

                return(new Level(lo, hi, gamma, ColorBgra.FromColor(Color.Black), ColorBgra.FromColor(Color.White)));
            }