protected CurvesEffectConfigToken(CurvesEffectConfigToken copyMe)
     : base(copyMe)
 {
     this.uop = copyMe.Uop;
     this.colorTransferMode = copyMe.ColorTransferMode;
     this.controlPoints = (SortedList<int, int>[])copyMe.controlPoints.Clone();
 }
 protected CurvesEffectConfigToken(CurvesEffectConfigToken copyMe)
     : base(copyMe)
 {
     this.uop = copyMe.Uop;
     this.colorTransferMode = copyMe.ColorTransferMode;
     this.controlPoints     = (SortedList <int, int>[])copyMe.controlPoints.Clone();
 }
        private UnaryPixelOp MakeUop(SortedList <int, int>[] controlPoints, ColorTransferMode mode)
        {
            UnaryPixelOp op;

            byte[][] transferCurves;
            int      entries;

            switch (mode)
            {
            case ColorTransferMode.Rgb:
                var cc = new ChannelCurveOp();
                transferCurves = new byte[][] { cc.CurveR, cc.CurveG, cc.CurveB };
                entries        = 256;
                op             = cc;
                break;

            case ColorTransferMode.Luminosity:
                var lc = new LuminosityCurveOp();
                transferCurves = new byte[][] { lc.Curve };
                entries        = 256;
                op             = lc;
                break;

            default:
                throw new InvalidEnumArgumentException();
            }


            int channels = transferCurves.Length;

            for (int channel = 0; channel < channels; channel++)
            {
                var channelControlPoints = controlPoints[channel];
                var xa = channelControlPoints.Keys;
                var ya = channelControlPoints.Values;
                SplineInterpolator interpolator = new SplineInterpolator();
                int length = channelControlPoints.Count;

                for (int i = 0; i < length; i++)
                {
                    interpolator.Add(xa[i], ya[i]);
                }

                for (int i = 0; i < entries; i++)
                {
                    transferCurves[channel][i] = Utility.ClampToByte(interpolator.Interpolate(i));
                }
            }

            return(op);
        }
        public CurvesEffectConfigToken()
        {
            controlPoints = new SortedList <int, int> [1];

            for (int i = 0; i < this.controlPoints.Length; ++i)
            {
                SortedList <int, int> newList = new SortedList <int, int>();

                newList.Add(0, 0);
                newList.Add(255, 255);
                controlPoints[i] = newList;
            }

            colorTransferMode = ColorTransferMode.Luminosity;
        }
        public CurvesEffectConfigToken()
        {
            controlPoints = new SortedList<int, int>[1];

            for (int i = 0; i < this.controlPoints.Length; ++i)
            {
                SortedList<int, int> newList = new SortedList<int, int>();

                newList.Add(0, 0);
                newList.Add(255, 255);
                controlPoints[i] = newList;
            }

            colorTransferMode = ColorTransferMode.Luminosity;
        }
		private UnaryPixelOp MakeUop (SortedList<int, int>[] controlPoints, ColorTransferMode mode)
		{
			UnaryPixelOp op;
			byte[][] transferCurves;
			int entries;

			switch (mode) {
				case ColorTransferMode.Rgb:
					var cc = new ChannelCurveOp ();
					transferCurves = new byte[][] { cc.CurveR, cc.CurveG, cc.CurveB };
					entries = 256;
					op = cc;
					break;

				case ColorTransferMode.Luminosity:
					var lc = new LuminosityCurveOp ();
					transferCurves = new byte[][] { lc.Curve };
					entries = 256;
					op = lc;
					break;

				default:
					throw new InvalidEnumArgumentException ();
			}


			int channels = transferCurves.Length;

			for (int channel = 0; channel < channels; channel++) {
				var channelControlPoints = controlPoints[channel];
				var xa = channelControlPoints.Keys;
				var ya = channelControlPoints.Values;
				SplineInterpolator interpolator = new SplineInterpolator ();
				int length = channelControlPoints.Count;

				for (int i = 0; i < length; i++) {
					interpolator.Add (xa[i], ya[i]);
				}

				for (int i = 0; i < entries; i++) {
					transferCurves[channel][i] = Utility.ClampToByte (interpolator.Interpolate (i));
				}
			}

			return op;
		}
Пример #7
0
        public override bool LaunchConfiguration()
        {
            CurvesDialog dialog = new CurvesDialog ();
            int response = dialog.Run ();

            if (response == (int)Gtk.ResponseType.Ok) {

                control_points = dialog.ControlPoints;
                mode = dialog.Mode;

                dialog.Destroy ();
                return true;
            }

            dialog.Destroy ();
            return false;
        }
Пример #8
0
        //private EnumLocalizer colorTransferNames = EnumLocalizer.Create(typeof(ColorTransferMode));

        //private void modeComboBox_SelectedIndexChanged(object sender, System.EventArgs e)
        //{
        //    ColorTransferMode colorTransferMode;

        //    if (modeComboBox.SelectedIndex >= 0)
        //    {
        //        colorTransferMode = (ColorTransferMode)colorTransferNames.LocalizedNameToEnumValue(modeComboBox.SelectedItem.ToString());
        //    }
        //    else
        //    {
        //        colorTransferMode = ColorTransferMode.Rgb;
        //    }
        //    UpdateColorTransferMode(colorTransferMode);
        //}

        private void UpdateColorTransferMode(ColorTransferMode colorTransferMode)
        {
            CurveControl newCurveControl;

            newCurveControl = curveControls[colorTransferMode];

            if (curveControl != newCurveControl)
            {
                tableLayoutMain.Controls.Remove(curveControl);
                curveControl             = newCurveControl;
                curveControl.Bounds      = new Rectangle(0, 0, 258, 258);
                curveControl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                //curveControl.ResetControlPoints();
                tableLayoutMain.SetColumnSpan(this.curveControl, 3);
                curveControl.Dock                = System.Windows.Forms.DockStyle.Fill;
                curveControl.ValueChanged       += curveControlValueChangedDelegate;
                curveControl.CoordinatesChanged += curveControlCoordinatesChangedDelegate;
                tableLayoutMain.Controls.Add(curveControl, 1, 2);

                int channels = newCurveControl.Channels;

                //maskCheckBoxes = new CheckBox[channels];

                //for (int i = 0; i < channels; ++i)
                //{
                //    CheckBox checkbox = new CheckBox();

                //    checkbox.Dock = DockStyle.Fill;
                //    checkbox.Checked = curveControl.GetSelected(i);
                //    checkbox.CheckedChanged += maskCheckChanged;
                //    checkbox.Text = curveControl.GetChannelName(i);

                //    maskCheckBoxes[i] = checkbox;
                //}

                //UpdateCheckboxEnables();
            }

            if (finishTokenOnDropDownChanged)
            {
                FinishTokenUpdate();
            }
        }
 public CurvesEffect(SortedList <int, int>[] controlPoints, ColorTransferMode mode)
 {
     op = MakeUop(controlPoints, mode);
 }
		public CurvesEffect (SortedList<int, int>[] controlPoints, ColorTransferMode mode)
		{
			op = MakeUop (controlPoints, mode);
		}
Пример #11
0
 protected void InitTokenFromDialog()
 {
     ColorTransferMode = curveControl.ColorTransferMode;
     ControlPoints     = (SortedList <int, int>[])curveControl.ControlPoints.Clone();
 }