protected override void InitDialogFromToken(EffectConfigToken effectToken)
        {
            UnaryPixelOps.Level levels = ((LevelsEffectConfigToken)effectToken).Levels;

            float gamma = MaskGamma(levels);
            int   lo    = MaskAvg(levels.ColorOutLow);
            int   hi    = MaskAvg(levels.ColorOutHigh);
            int   md    = (int)(lo + (hi - lo) * Math.Pow(0.5, gamma));

            outputHiUpDown.Value    = hi;
            outputGammaUpDown.Value = (decimal)gamma;
            outputLowUpDown.Value   = lo;
            inputHiUpDown.Value     = MaskAvg(levels.ColorInHigh);
            inputLoUpDown.Value     = MaskAvg(levels.ColorInLow);

            gradientOutput.SetValue(0, lo);
            gradientOutput.SetValue(1, md);
            gradientOutput.SetValue(2, hi);

            swatchInHigh.BackColor = levels.ColorInHigh.ToColor();
            swatchInLow.BackColor  = levels.ColorInLow.ToColor();
            swatchOutMid.BackColor = levels.Apply(((HistogramRgb)histogramInput.Histogram).GetMeanColor()).ToColor();
            swatchOutMid.Invalidate();
            swatchOutHigh.BackColor = levels.ColorOutHigh.ToColor();
            swatchOutLow.BackColor  = levels.ColorOutLow.ToColor();
        }
        protected override void InitTokenFromDialog()
        {
            UnaryPixelOps.Level levels = ((LevelsEffectConfigToken)theEffectToken).Levels;

            levels.ColorOutHigh = UpdateByMask(levels.ColorOutHigh, (byte)outputHiUpDown.Value);
            levels.ColorOutLow  = UpdateByMask(levels.ColorOutLow, (byte)outputLowUpDown.Value);

            levels.ColorInHigh = UpdateByMask(levels.ColorInHigh, (byte)inputHiUpDown.Value);
            levels.ColorInLow  = UpdateByMask(levels.ColorInLow, (byte)inputLoUpDown.Value);

            UpdateGammaByMask(levels, (float)outputGammaUpDown.Value);

            swatchInHigh.BackColor = levels.ColorInHigh.ToColor();
            swatchInHigh.Invalidate();

            swatchInLow.BackColor = levels.ColorInLow.ToColor();
            swatchInLow.Invalidate();

            swatchOutHigh.BackColor = levels.ColorOutHigh.ToColor();
            swatchOutHigh.Invalidate();

            swatchOutMid.BackColor = levels.Apply(((HistogramRgb)histogramInput.Histogram).GetMeanColor()).ToColor();
            swatchOutMid.Invalidate();

            swatchOutLow.BackColor = levels.ColorOutLow.ToColor();
            swatchOutLow.Invalidate();
        }
Example #3
0
 public override void Render(Surface src, Surface dst, Rectangle[] rois, int startIndex, int length)
 {
     if (_levels.isValid)
     {
         _levels.Apply(dst, src, rois, startIndex, length);
     }
 }
Example #4
0
        public override void Render(ImageSurface src, ImageSurface dest, Gdk.Rectangle[] rois)
        {
            if (op == null)
            {
                HistogramRgb histogram = new HistogramRgb();
                histogram.UpdateHistogram(src, new Gdk.Rectangle(0, 0, src.Width, src.Height));

                op = histogram.MakeLevelsAuto();
            }

            if (op.isValid)
            {
                op.Apply(dest, src, rois);
            }
        }
Example #5
0
        public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs,
                                    Rectangle[] rois, int startIndex, int length)
        {
            if (levels == null)
            {
                HistogramRgb histogram = new HistogramRgb();
                histogram.UpdateHistogram(srcArgs.Surface, this.EnvironmentParameters.GetSelection(dstArgs.Bounds));
                levels = histogram.MakeLevelsAuto();
            }

            if (levels.isValid)
            {
                levels.Apply(dstArgs.Surface, srcArgs.Surface, rois, startIndex, length);
            }
        }
Example #6
0
 public override void Render(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs, Rectangle[] rois, int startIndex, int length)
 {
     UnaryPixelOps.Level levels = (parameters as LevelsEffectConfigToken).Levels;
     levels.Apply(dstArgs.Surface, srcArgs.Surface, rois, startIndex, length);
 }