/// <summary> /// Creates a new project /// </summary> /// <param name="type">The type of the project</param> public static void NewProject(ProjectType type) { Close(); HasInit = false; UsedProgram = type; switch (type) { case ProjectType.LapseStudio: CurrentProject = new ProjectLS(); break; case ProjectType.CameraRaw: CurrentProject = new ProjectACR(); break; case ProjectType.RawTherapee: CurrentProject = new ProjectRT(); break; } CurrentProject.ProgressChanged += OnProgressChanged; CurrentProject.FramesLoaded += OnFramesLoaded; CurrentProject.BrightnessCalculated += OnBrightnessCalculated; CurrentProject.WorkDone += OnWorkDone; }
internal static PP3[] Do(ProjectRT CurProj) { PP3[] Output = new PP3[CurProj.Frames.Count]; PP3 typepp3 = ((FrameRT)CurProj.Frames.First(t => t.IsKeyframe)).PP3File; if (CurProj.KeyframeCount == 1) { for (int i = 0; i < CurProj.Frames.Count; i++) { Output[i] = typepp3.Copy(); } return Output; } for (int j = 0; j < CurProj.Frames.Count; j++) { Output[j] = typepp3.Copy(); } for (int i = 0; i < typepp3.Values.Count; i++) { List<KeyValuePair<int, object>> Values = new List<KeyValuePair<int, object>>(); Type CurType = typepp3.Values.ElementAt(i).Value.Value.GetType(); string valname = typepp3.Values.ElementAt(i).Key; for (int j = 0; j < CurProj.Frames.Count; j++) { if (CurProj.Frames[j].IsKeyframe) { Values.Add(new KeyValuePair<int, object>(j, ((FrameRT)CurProj.Frames[j]).PP3File.Values[valname].Value)); } else if (j == 0) { Values.Add(new KeyValuePair<int, object>(j, ((FrameRT)CurProj.Frames.First(t => t.IsKeyframe)).PP3File.Values[valname].Value)); } else if (j == CurProj.Frames.Count - 1) { Values.Add(new KeyValuePair<int, object>(j, ((FrameRT)CurProj.Frames.Last(t => t.IsKeyframe)).PP3File.Values[valname].Value)); } } if (CurType != typeof(bool) && CurType != typeof(string)) { PointD[] InVals = new PointD[Values.Count]; PointD[] OutVals = new PointD[CurProj.Frames.Count]; if (CurType == typeof(int)) { for (int k = 0; k < Values.Count; k++) { InVals[k] = new PointD(Values[k].Key, (int)Convert.ChangeType(Values[k].Value, typeof(int))); } OutVals = Do(InVals, CurProj.Frames.Count); for (int k = 0; k < CurProj.Frames.Count; k++) { if (((FrameRT)CurProj.Frames[k]).PP3File != null) { Output[k].Path = ((FrameRT)CurProj.Frames[k]).PP3File.Path; Output[k].Compensation = ((FrameRT)CurProj.Frames[k]).PP3File.Compensation; Output[k].FileVersion = ((FrameRT)CurProj.Frames[k]).PP3File.FileVersion; Output[k].NewCompensation = ((FrameRT)CurProj.Frames[k]).PP3File.NewCompensation; } Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, (int)OutVals[k].Y, typepp3.Values[valname].min, typepp3.Values[valname].max); } } else if (CurType == typeof(double)) { for (int k = 0; k < Values.Count; k++) { InVals[k] = new PointD(Values[k].Key, (float)Convert.ChangeType(Values[k].Value, typeof(float))); } OutVals = Do(InVals, CurProj.Frames.Count); for (int k = 0; k < CurProj.Frames.Count; k++) { if (((FrameRT)CurProj.Frames[k]).PP3File != null) { Output[k].Path = ((FrameRT)CurProj.Frames[k]).PP3File.Path; Output[k].Compensation = ((FrameRT)CurProj.Frames[k]).PP3File.Compensation; Output[k].FileVersion = ((FrameRT)CurProj.Frames[k]).PP3File.FileVersion; Output[k].NewCompensation = ((FrameRT)CurProj.Frames[k]).PP3File.NewCompensation; } Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, (double)OutVals[k].Y, typepp3.Values[valname].min, typepp3.Values[valname].max); } } else if (CurType.BaseType == typeof(PP3Curve)) { if (CurType == typeof(PP3Curve_Linear)) { int index = 0; for (int k = 0; k < CurProj.Frames.Count; k++) { if (((FrameRT)CurProj.Frames[k]).PP3File != null) { Output[k].Path = ((FrameRT)CurProj.Frames[k]).PP3File.Path; Output[k].Compensation = ((FrameRT)CurProj.Frames[k]).PP3File.Compensation; Output[k].FileVersion = ((FrameRT)CurProj.Frames[k]).PP3File.FileVersion; Output[k].NewCompensation = ((FrameRT)CurProj.Frames[k]).PP3File.NewCompensation; } Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, Values[index].Value, typepp3.Values[valname].min, typepp3.Values[valname].max); if (Values[index].Key == k) { index++; } } } else { PP3Curve[] OutCurves = Do(Values); for (int k = 0; k < CurProj.Frames.Count; k++) { if (((FrameRT)CurProj.Frames[k]).PP3File != null) { Output[k].Path = ((FrameRT)CurProj.Frames[k]).PP3File.Path; Output[k].Compensation = ((FrameRT)CurProj.Frames[k]).PP3File.Compensation; Output[k].FileVersion = ((FrameRT)CurProj.Frames[k]).PP3File.FileVersion; Output[k].NewCompensation = ((FrameRT)CurProj.Frames[k]).PP3File.NewCompensation; } Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, OutCurves[k], typepp3.Values[valname].min, typepp3.Values[valname].max); } } } else { throw new InterpolationNotPossibleException("Couldn't interpolate this kind of Value: " + CurType.FullName); } } else { int index = 0; for (int k = 0; k < CurProj.Frames.Count; k++) { Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, Values[index].Value, typepp3.Values[valname].min, typepp3.Values[valname].max); if (Values[index].Key == k) { index++; } } } } return Output; }
internal static PP3[] Do(ProjectRT CurProj) { PP3[] Output = new PP3[CurProj.Frames.Count]; PP3 typepp3 = ((FrameRT)CurProj.Frames.First(t => t.IsKeyframe)).PP3File; if (CurProj.KeyframeCount == 1) { for (int i = 0; i < CurProj.Frames.Count; i++) { Output[i] = typepp3.Copy(); } return(Output); } for (int j = 0; j < CurProj.Frames.Count; j++) { Output[j] = typepp3.Copy(); } for (int i = 0; i < typepp3.Values.Count; i++) { List <KeyValuePair <int, object> > Values = new List <KeyValuePair <int, object> >(); Type CurType = typepp3.Values.ElementAt(i).Value.Value.GetType(); string valname = typepp3.Values.ElementAt(i).Key; for (int j = 0; j < CurProj.Frames.Count; j++) { if (CurProj.Frames[j].IsKeyframe) { Values.Add(new KeyValuePair <int, object>(j, ((FrameRT)CurProj.Frames[j]).PP3File.Values[valname].Value)); } else if (j == 0) { Values.Add(new KeyValuePair <int, object>(j, ((FrameRT)CurProj.Frames.First(t => t.IsKeyframe)).PP3File.Values[valname].Value)); } else if (j == CurProj.Frames.Count - 1) { Values.Add(new KeyValuePair <int, object>(j, ((FrameRT)CurProj.Frames.Last(t => t.IsKeyframe)).PP3File.Values[valname].Value)); } } if (CurType != typeof(bool) && CurType != typeof(string)) { PointD[] InVals = new PointD[Values.Count]; PointD[] OutVals = new PointD[CurProj.Frames.Count]; if (CurType == typeof(int)) { for (int k = 0; k < Values.Count; k++) { InVals[k] = new PointD(Values[k].Key, (int)Convert.ChangeType(Values[k].Value, typeof(int))); } OutVals = Do(InVals, CurProj.Frames.Count); for (int k = 0; k < CurProj.Frames.Count; k++) { if (((FrameRT)CurProj.Frames[k]).PP3File != null) { Output[k].Path = ((FrameRT)CurProj.Frames[k]).PP3File.Path; Output[k].Compensation = ((FrameRT)CurProj.Frames[k]).PP3File.Compensation; Output[k].FileVersion = ((FrameRT)CurProj.Frames[k]).PP3File.FileVersion; Output[k].NewCompensation = ((FrameRT)CurProj.Frames[k]).PP3File.NewCompensation; } Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, (int)OutVals[k].Y, typepp3.Values[valname].min, typepp3.Values[valname].max); } } else if (CurType == typeof(double)) { for (int k = 0; k < Values.Count; k++) { InVals[k] = new PointD(Values[k].Key, (float)Convert.ChangeType(Values[k].Value, typeof(float))); } OutVals = Do(InVals, CurProj.Frames.Count); for (int k = 0; k < CurProj.Frames.Count; k++) { if (((FrameRT)CurProj.Frames[k]).PP3File != null) { Output[k].Path = ((FrameRT)CurProj.Frames[k]).PP3File.Path; Output[k].Compensation = ((FrameRT)CurProj.Frames[k]).PP3File.Compensation; Output[k].FileVersion = ((FrameRT)CurProj.Frames[k]).PP3File.FileVersion; Output[k].NewCompensation = ((FrameRT)CurProj.Frames[k]).PP3File.NewCompensation; } Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, (double)OutVals[k].Y, typepp3.Values[valname].min, typepp3.Values[valname].max); } } else if (CurType.BaseType == typeof(PP3Curve)) { if (CurType == typeof(PP3Curve_Linear)) { int index = 0; for (int k = 0; k < CurProj.Frames.Count; k++) { if (((FrameRT)CurProj.Frames[k]).PP3File != null) { Output[k].Path = ((FrameRT)CurProj.Frames[k]).PP3File.Path; Output[k].Compensation = ((FrameRT)CurProj.Frames[k]).PP3File.Compensation; Output[k].FileVersion = ((FrameRT)CurProj.Frames[k]).PP3File.FileVersion; Output[k].NewCompensation = ((FrameRT)CurProj.Frames[k]).PP3File.NewCompensation; } Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, Values[index].Value, typepp3.Values[valname].min, typepp3.Values[valname].max); if (Values[index].Key == k) { index++; } } } else { PP3Curve[] OutCurves = Do(Values); for (int k = 0; k < CurProj.Frames.Count; k++) { if (((FrameRT)CurProj.Frames[k]).PP3File != null) { Output[k].Path = ((FrameRT)CurProj.Frames[k]).PP3File.Path; Output[k].Compensation = ((FrameRT)CurProj.Frames[k]).PP3File.Compensation; Output[k].FileVersion = ((FrameRT)CurProj.Frames[k]).PP3File.FileVersion; Output[k].NewCompensation = ((FrameRT)CurProj.Frames[k]).PP3File.NewCompensation; } Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, OutCurves[k], typepp3.Values[valname].min, typepp3.Values[valname].max); } } } else { throw new InterpolationNotPossibleException("Couldn't interpolate this kind of Value: " + CurType.FullName); } } else { int index = 0; for (int k = 0; k < CurProj.Frames.Count; k++) { Output[k].Values[valname] = new PP3.PP3entry(typepp3.Values[valname].Name, Values[index].Value, typepp3.Values[valname].min, typepp3.Values[valname].max); if (Values[index].Key == k) { index++; } } } } return(Output); }