Пример #1
0
        private void DrawSpline(Context g)
        {
            var infos = GetDrawingInfos ();

            foreach (var controlPoints in ControlPoints) {

                int points = controlPoints.Count;
                SplineInterpolator interpolator = new SplineInterpolator ();
                IList<int> xa = controlPoints.Keys;
                IList<int> ya = controlPoints.Values;
                PointD[] line = new PointD [size];

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

                for (int i = 0; i < line.Length; i++) {
                   			line[i].X = (float)i;
                            line[i].Y = (float)(Utility.Clamp(size - 1 - interpolator.Interpolate (i), 0, size - 1));

                        }

                g.LineWidth = 2;
                g.LineJoin = LineJoin.Round;

                g.MoveTo (line [0]);
                for (int i = 1; i < line.Length; i++)
                    g.LineTo (line [i]);

                infos.MoveNext ();
                var info = infos.Current;

                g.Color = info.Color;
                g.LineWidth = info.IsActive ? 2 : 1;
                g.Stroke ();
            }
        }
Пример #2
0
        private UnaryPixelOp MakeUop()
        {
            UnaryPixelOp op;
            byte[][] transferCurves;
            int entries;

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

                case ColorTransferMode.Luminosity:
                    UnaryPixelOps.LuminosityCurve lc = new UnaryPixelOps.LuminosityCurve();
                    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++) {
                SortedList<int, int> channelControlPoints = control_points[channel];
                IList<int> xa = channelControlPoints.Keys;
                IList<int> 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;
        }