private UnaryPixelOp MakeUop() { UnaryPixelOp op; byte[][] transferCurves; int entries; switch (Data.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 = Data.ControlPoints ![channel]; // NRT - Code expects this to be not-null
private UnaryPixelOp MakeUop() { UnaryPixelOp op; byte[][] transferCurves; int entries; switch (Data.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 = Data.ControlPoints[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); }
private UnaryPixelOp MakeUop() { UnaryPixelOp uopRet; byte[][] transferCurves; int entries; switch (colorTransferMode) { case ColorTransferMode.Rgb: UnaryPixelOps.ChannelCurve cc = new UnaryPixelOps.ChannelCurve(); transferCurves = new byte[][] { cc.CurveR, cc.CurveG, cc.CurveB }; entries = 256; uopRet = cc; break; case ColorTransferMode.Luminosity: UnaryPixelOps.LuminosityCurve lc = new UnaryPixelOps.LuminosityCurve(); transferCurves = new byte[][] { lc.Curve }; entries = 256; uopRet = lc; break; default: throw new InvalidEnumArgumentException(); } int channels = transferCurves.Length; for (int channel = 0; channel < channels; ++channel) { SortedList<int, int> channelControlPoints = controlPoints[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 uopRet; }