Example #1
0
        /// <summary>
        /// 将控件参数传递到参数对象中
        /// </summary>
        protected override void CollectArguments()
        {
            if (_arg == null)
            {
                return;
            }
            CurveAdjustProcessorArg actualArg    = _arg as CurveAdjustProcessorArg;
            IInterpolator           interpolator = GetInterpolator();

            if (curveControl.Channels == 3)
            {
                for (int i = 0; i < curveControl.Channels; i++)
                {
                    interpolator.Clear();
                    CurveControl          curve = curveControl;// curveControls[CA.ColorTransferMode.Rgb];
                    SortedList <int, int> cps   = curve.ControlPoints[i];
                    for (int s = 0; s < cps.Count; s++)
                    {
                        interpolator.Add(cps.Keys[s], cps.Values[s]);
                    }
                    byte[] rgbMap = new byte[curveControl.Entries];
                    for (int j = 0; j < curveControl.Entries; j++)
                    {
                        rgbMap[j] = (byte)Utility.Clamp(interpolator.Interpolate((byte)j), 0, curveControl.Entries - 1);
                    }
                    if (i == 0)
                    {
                        actualArg.Red.Values = rgbMap;
                    }
                    else if (i == 1)
                    {
                        actualArg.Green.Values = rgbMap;
                    }
                    else if (i == 2)
                    {
                        actualArg.Blue.Values = rgbMap;
                    }
                }
                actualArg.RGB.Values = null;
            }
            else
            {
                interpolator.Clear();
                CurveControl          curve = curveControl;// curveControls[CA.ColorTransferMode.Luminosity];
                SortedList <int, int> cps   = curve.ControlPoints[0];
                for (int s = 0; s < cps.Count; s++)
                {
                    interpolator.Add(cps.Keys[s], cps.Values[s]);
                }
                byte[] rgbMap = new byte[curveControl.Entries];
                for (int j = 0; j < curveControl.Entries; j++)
                {
                    rgbMap[j] = (byte)Utility.Clamp(interpolator.Interpolate((byte)j), 0, curveControl.Entries - 1);
                }
                actualArg.RGB.Values   = rgbMap;
                actualArg.Red.Values   = null;
                actualArg.Green.Values = null;
                actualArg.Blue.Values  = null;
            }
            base.CollectArguments();
        }