Пример #1
0
        public static PP3Curve GetCurve(string rawdata)
        {
            string[]    vals    = rawdata.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            CultureInfo culture = new CultureInfo("en-US");

            switch (vals.Length)
            {
            case 1:
                return(new PP3Curve_Linear());

            case 2:
            case 3:
            case 4:
                PP3Curve_Array Curve_Arr = new PP3Curve_Array();
                for (int i = 0; i < vals.Length; i++)
                {
                    Curve_Arr.DataPoints.Add(Convert.ToInt32(vals[i]));
                }
                return(Curve_Arr);

            default:
                switch (vals[0])
                {
                case "1":
                    PP3Curve_Custom Curve_Cus = new PP3Curve_Custom();
                    for (int i = 1; i < vals.Length; i += 2)
                    {
                        float x = (float)Convert.ToDouble(vals[i], culture);
                        float y = (float)Convert.ToDouble(vals[i + 1], culture);
                        Curve_Cus.DataPoints.Add(new PointD(x, y));
                    }
                    return(Curve_Cus);

                case "2":
                    PP3Curve_Parametric Curve_Par = new PP3Curve_Parametric();
                    Curve_Par.Zones[0]   = Convert.ToDouble(vals[1], culture);
                    Curve_Par.Zones[1]   = Convert.ToDouble(vals[2], culture);
                    Curve_Par.Zones[2]   = Convert.ToDouble(vals[3], culture);
                    Curve_Par.Highlights = Convert.ToDouble(vals[4], culture);
                    Curve_Par.Lights     = Convert.ToDouble(vals[5], culture);
                    Curve_Par.Darks      = Convert.ToDouble(vals[6], culture);
                    Curve_Par.Shadows    = Convert.ToDouble(vals[7], culture);
                    return(Curve_Par);

                case "3":
                    PP3Curve_ControlCage Curve_Con = new PP3Curve_ControlCage();
                    for (int i = 1; i < vals.Length; i += 2)
                    {
                        float x = (float)Convert.ToDouble(vals[i], culture);
                        float y = (float)Convert.ToDouble(vals[i + 1], culture);
                        Curve_Con.DataPoints.Add(new PointD(x, y));
                    }
                    return(Curve_Con);

                default:
                    return(null);
                }
            }
        }
Пример #2
0
        public static PP3Curve GetCurve(string rawdata)
        {
            string[] vals = rawdata.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            CultureInfo culture = new CultureInfo("en-US");

            switch (vals.Length)
            {
                case 1:
                    return new PP3Curve_Linear();

                case 2:
                case 3:
                case 4:
                    PP3Curve_Array Curve_Arr = new PP3Curve_Array();
                    for (int i = 0; i < vals.Length; i++) { Curve_Arr.DataPoints.Add(Convert.ToInt32(vals[i])); }
                    return Curve_Arr;

                default:
                    switch (vals[0])
                    {
                        case "1":
                            PP3Curve_Custom Curve_Cus = new PP3Curve_Custom();
                            for (int i = 1; i < vals.Length; i += 2)
                            {
                                float x = (float)Convert.ToDouble(vals[i], culture);
                                float y = (float)Convert.ToDouble(vals[i + 1], culture);
                                Curve_Cus.DataPoints.Add(new PointD(x, y));
                            }
                            return Curve_Cus;

                        case "2":
                            PP3Curve_Parametric Curve_Par = new PP3Curve_Parametric();
                            Curve_Par.Zones[0] = Convert.ToDouble(vals[1], culture);
                            Curve_Par.Zones[1] = Convert.ToDouble(vals[2], culture);
                            Curve_Par.Zones[2] = Convert.ToDouble(vals[3], culture);
                            Curve_Par.Highlights = Convert.ToDouble(vals[4], culture);
                            Curve_Par.Lights = Convert.ToDouble(vals[5], culture);
                            Curve_Par.Darks = Convert.ToDouble(vals[6], culture);
                            Curve_Par.Shadows = Convert.ToDouble(vals[7], culture);
                            return Curve_Par;

                        case "3":
                            PP3Curve_ControlCage Curve_Con = new PP3Curve_ControlCage();
                            for (int i = 1; i < vals.Length; i += 2)
                            {
                                float x = (float)Convert.ToDouble(vals[i], culture);
                                float y = (float)Convert.ToDouble(vals[i + 1], culture);
                                Curve_Con.DataPoints.Add(new PointD(x, y));
                            }
                            return Curve_Con;

                        default:
                            return null;
                    }
            }
        }
Пример #3
0
        internal static PP3Curve[] Do(List<KeyValuePair<int, object>> Input)
        {
            Type CurType = Input[0].Value.GetType();
            int Pointcount, step = 1;

            if (CurType == typeof(PP3Curve_Array))
            {
                Pointcount = ((PP3Curve_Array)Input[0].Value).DataPoints.Count;
                if (Input.Any(t => ((PP3Curve_Array)t.Value).DataPoints.Count != Pointcount)) { throw new InterpolationNotPossibleException("Pointcount of curve is not consistet!"); }
            }
            else if (CurType == typeof(PP3Curve_ControlCage))
            {
                Pointcount = ((PP3Curve_ControlCage)Input[0].Value).DataPoints.Count;
                if (Input.Any(t => ((PP3Curve_ControlCage)t.Value).DataPoints.Count != Pointcount)) { throw new InterpolationNotPossibleException("Pointcount of curve is not consistet!"); }
            }
            else if (CurType == typeof(PP3Curve_Custom))
            {
                step = 2;
                Pointcount = ((PP3Curve_Custom)Input[0].Value).DataPoints.Count * 2;
                if (Input.Any(t => ((PP3Curve_Custom)t.Value).DataPoints.Count * 2 != Pointcount)) { throw new InterpolationNotPossibleException("Pointcount of curve is not consistet!"); }
            }
            else if (CurType == typeof(PP3Curve_Parametric)) { Pointcount = 7; }
            else { throw new InterpolationNotPossibleException(); }

            //check if it's possible to interpolate
            if (Input.Any(t => t.Value.GetType() != CurType)) { throw new InterpolationNotPossibleException("Curvetype is not consistet!"); }

            //start to interpolate
            PointD[][] InPoints = new PointD[Pointcount][];

            //Curves to points
            for (int i = 0; i < Pointcount; i += step)
            {
                if (InPoints[i] == null) { InPoints[i] = new PointD[Input.Count]; }

                for (int j = 0; j < Input.Count; j++)
                {
                    if (CurType == typeof(PP3Curve_Array)) { InPoints[i][j] = new PointD(Input[j].Key, ((PP3Curve_Array)Input[j].Value).DataPoints[i]); }
                    else if (CurType == typeof(PP3Curve_ControlCage)) { InPoints[i][j] = ((PP3Curve_ControlCage)Input[j].Value).DataPoints[i]; }
                    else if (CurType == typeof(PP3Curve_Custom))
                    {
                        if (InPoints[i + 1] == null) { InPoints[i + 1] = new PointD[Input.Count]; }
                        InPoints[i][j] = new PointD(j, ((PP3Curve_Custom)Input[j].Value).DataPoints[i / 2].X);
                        InPoints[i + 1][j] = new PointD(j, ((PP3Curve_Custom)Input[j].Value).DataPoints[i / 2].Y);
                    }
                    else if (CurType == typeof(PP3Curve_Parametric))
                    {
                        InPoints[i][0] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[0].Value).Zones[0]);
                        InPoints[i][1] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[1].Value).Zones[1]);
                        InPoints[i][2] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[2].Value).Zones[2]);
                        InPoints[i][3] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[3].Value).Highlights);
                        InPoints[i][4] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[4].Value).Lights);
                        InPoints[i][5] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[5].Value).Darks);
                        InPoints[i][6] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[6].Value).Shadows);
                    }
                }
            }

            PointD[][] OutPoints = new PointD[Pointcount][];

            //interpolate points
            for (int i = 0; i < Pointcount; i++) { OutPoints[i] = Do(InPoints[i], ProjectManager.CurrentProject.Frames.Count); }

            PP3Curve[] Output = new PP3Curve[ProjectManager.CurrentProject.Frames.Count];

            //points back to curves
            for (int i = 0; i < ProjectManager.CurrentProject.Frames.Count; i++)
            {
                for (int j = 0; j < Pointcount; j += step)
                {
                    if (CurType == typeof(PP3Curve_Array))
                    {
                        if (Output[i] == null) { Output[i] = new PP3Curve_Array(); }
                        ((PP3Curve_Array)Output[i]).DataPoints.Add((int)OutPoints[j][i].Y);
                    }
                    else if (CurType == typeof(PP3Curve_ControlCage))
                    {
                        if (Output[i] == null) { Output[i] = new PP3Curve_ControlCage(); }
                        ((PP3Curve_ControlCage)Output[i]).DataPoints.Add(OutPoints[j][i]);
                    }
                    else if (CurType == typeof(PP3Curve_Custom))
                    {
                        if (Output[i] == null) { Output[i] = new PP3Curve_Custom(); }
                        ((PP3Curve_Custom)Output[i]).DataPoints.Add(new PointD(OutPoints[j][i].Y, OutPoints[j + 1][i].Y));
                    }
                    else if (CurType == typeof(PP3Curve_Parametric))
                    {
                        if (Output[i] == null) { Output[i] = new PP3Curve_Parametric(); }
                        ((PP3Curve_Parametric)Output[i]).Zones[0] = OutPoints[0][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Zones[1] = OutPoints[1][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Zones[2] = OutPoints[2][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Highlights = OutPoints[3][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Lights = OutPoints[4][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Darks = OutPoints[5][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Shadows = OutPoints[6][i].Y;
                        j = Pointcount;
                    }
                    else if (CurType == typeof(PP3Curve_HSV))
                    {
                        //TODO: check for HSV curve type (also in PP3Curve.cs); handling is the same as custom curve
                    }
                }
            }

            return Output;
        }
Пример #4
0
        internal static PP3Curve[] Do(List <KeyValuePair <int, object> > Input)
        {
            Type CurType = Input[0].Value.GetType();
            int  Pointcount, step = 1;

            if (CurType == typeof(PP3Curve_Array))
            {
                Pointcount = ((PP3Curve_Array)Input[0].Value).DataPoints.Count;
                if (Input.Any(t => ((PP3Curve_Array)t.Value).DataPoints.Count != Pointcount))
                {
                    throw new InterpolationNotPossibleException("Pointcount of curve is not consistet!");
                }
            }
            else if (CurType == typeof(PP3Curve_ControlCage))
            {
                Pointcount = ((PP3Curve_ControlCage)Input[0].Value).DataPoints.Count;
                if (Input.Any(t => ((PP3Curve_ControlCage)t.Value).DataPoints.Count != Pointcount))
                {
                    throw new InterpolationNotPossibleException("Pointcount of curve is not consistet!");
                }
            }
            else if (CurType == typeof(PP3Curve_Custom))
            {
                step       = 2;
                Pointcount = ((PP3Curve_Custom)Input[0].Value).DataPoints.Count * 2;
                if (Input.Any(t => ((PP3Curve_Custom)t.Value).DataPoints.Count * 2 != Pointcount))
                {
                    throw new InterpolationNotPossibleException("Pointcount of curve is not consistet!");
                }
            }
            else if (CurType == typeof(PP3Curve_Parametric))
            {
                Pointcount = 7;
            }
            else
            {
                throw new InterpolationNotPossibleException();
            }

            //check if it's possible to interpolate
            if (Input.Any(t => t.Value.GetType() != CurType))
            {
                throw new InterpolationNotPossibleException("Curvetype is not consistet!");
            }

            //start to interpolate
            PointD[][] InPoints = new PointD[Pointcount][];

            //Curves to points
            for (int i = 0; i < Pointcount; i += step)
            {
                if (InPoints[i] == null)
                {
                    InPoints[i] = new PointD[Input.Count];
                }

                for (int j = 0; j < Input.Count; j++)
                {
                    if (CurType == typeof(PP3Curve_Array))
                    {
                        InPoints[i][j] = new PointD(Input[j].Key, ((PP3Curve_Array)Input[j].Value).DataPoints[i]);
                    }
                    else if (CurType == typeof(PP3Curve_ControlCage))
                    {
                        InPoints[i][j] = ((PP3Curve_ControlCage)Input[j].Value).DataPoints[i];
                    }
                    else if (CurType == typeof(PP3Curve_Custom))
                    {
                        if (InPoints[i + 1] == null)
                        {
                            InPoints[i + 1] = new PointD[Input.Count];
                        }
                        InPoints[i][j]     = new PointD(j, ((PP3Curve_Custom)Input[j].Value).DataPoints[i / 2].X);
                        InPoints[i + 1][j] = new PointD(j, ((PP3Curve_Custom)Input[j].Value).DataPoints[i / 2].Y);
                    }
                    else if (CurType == typeof(PP3Curve_Parametric))
                    {
                        InPoints[i][0] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[0].Value).Zones[0]);
                        InPoints[i][1] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[1].Value).Zones[1]);
                        InPoints[i][2] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[2].Value).Zones[2]);
                        InPoints[i][3] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[3].Value).Highlights);
                        InPoints[i][4] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[4].Value).Lights);
                        InPoints[i][5] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[5].Value).Darks);
                        InPoints[i][6] = new PointD(Input[j].Key, (float)((PP3Curve_Parametric)Input[6].Value).Shadows);
                    }
                }
            }

            PointD[][] OutPoints = new PointD[Pointcount][];

            //interpolate points
            for (int i = 0; i < Pointcount; i++)
            {
                OutPoints[i] = Do(InPoints[i], ProjectManager.CurrentProject.Frames.Count);
            }

            PP3Curve[] Output = new PP3Curve[ProjectManager.CurrentProject.Frames.Count];

            //points back to curves
            for (int i = 0; i < ProjectManager.CurrentProject.Frames.Count; i++)
            {
                for (int j = 0; j < Pointcount; j += step)
                {
                    if (CurType == typeof(PP3Curve_Array))
                    {
                        if (Output[i] == null)
                        {
                            Output[i] = new PP3Curve_Array();
                        }
                        ((PP3Curve_Array)Output[i]).DataPoints.Add((int)OutPoints[j][i].Y);
                    }
                    else if (CurType == typeof(PP3Curve_ControlCage))
                    {
                        if (Output[i] == null)
                        {
                            Output[i] = new PP3Curve_ControlCage();
                        }
                        ((PP3Curve_ControlCage)Output[i]).DataPoints.Add(OutPoints[j][i]);
                    }
                    else if (CurType == typeof(PP3Curve_Custom))
                    {
                        if (Output[i] == null)
                        {
                            Output[i] = new PP3Curve_Custom();
                        }
                        ((PP3Curve_Custom)Output[i]).DataPoints.Add(new PointD(OutPoints[j][i].Y, OutPoints[j + 1][i].Y));
                    }
                    else if (CurType == typeof(PP3Curve_Parametric))
                    {
                        if (Output[i] == null)
                        {
                            Output[i] = new PP3Curve_Parametric();
                        }
                        ((PP3Curve_Parametric)Output[i]).Zones[0]   = OutPoints[0][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Zones[1]   = OutPoints[1][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Zones[2]   = OutPoints[2][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Highlights = OutPoints[3][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Lights     = OutPoints[4][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Darks      = OutPoints[5][i].Y;
                        ((PP3Curve_Parametric)Output[i]).Shadows    = OutPoints[6][i].Y;
                        j = Pointcount;
                    }
                    else if (CurType == typeof(PP3Curve_HSV))
                    {
                        //TODO: check for HSV curve type (also in PP3Curve.cs); handling is the same as custom curve
                    }
                }
            }

            return(Output);
        }