corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /// <summary>**************************************************************************
2 ///
3 /// $Id: LookUpTable8Interp.java,v 1.1 2002/07/25 14:56:48 grosbois Exp $
4 ///
5 /// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
6 /// $Date $
7 /// ***************************************************************************
8 /// </summary>
9 using System;
10 using ICCCurveType = CSJ2K.Icc.Tags.ICCCurveType;
11 namespace CSJ2K.Icc.Lut
12 {
13  
14  
15 /// <summary> An interpolated 8 bit lut
16 ///
17 /// </summary>
18 /// <version> 1.0
19 /// </version>
20 /// <author> Bruce A.Kern
21 /// </author>
22 public class LookUpTable8Interp:LookUpTable8
23 {
24  
25 /// <summary> Construct the lut from the curve data</summary>
26 /// <oaram> curve the data </oaram>
27 /// <oaram> dwNumInput the lut size </oaram>
28 /// <oaram> dwMaxOutput the lut max value </oaram>
29 public LookUpTable8Interp(ICCCurveType curve, int dwNumInput, byte dwMaxOutput):base(curve, dwNumInput, dwMaxOutput)
30 {
31  
32 int dwLowIndex, dwHighIndex; // Indices of interpolation points
33 double dfLowIndex, dfHighIndex; // FP indices of interpolation points
34 double dfTargetIndex; // Target index into interpolation table
35 double dfRatio; // Ratio of LUT input points to curve values
36 double dfLow, dfHigh; // Interpolation values
37 double dfOut; // Output LUT value
38  
39 dfRatio = (double) (curve.count - 1) / (double) (dwNumInput - 1);
40  
41 for (int i = 0; i < dwNumInput; i++)
42 {
43 dfTargetIndex = (double) i * dfRatio;
44 dfLowIndex = System.Math.Floor(dfTargetIndex);
45 //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
46 dwLowIndex = (int) dfLowIndex;
47 dfHighIndex = System.Math.Ceiling(dfTargetIndex);
48 //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
49 dwHighIndex = (int) dfHighIndex;
50  
51 if (dwLowIndex == dwHighIndex)
52 dfOut = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
53 else
54 {
55 dfLow = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
56 dfHigh = ICCCurveType.CurveToDouble(curve.entry(dwHighIndex));
57 dfOut = dfLow + (dfHigh - dfLow) * (dfTargetIndex - dfLowIndex);
58 }
59  
60 //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
61 lut[i] = (byte) System.Math.Floor(dfOut * dwMaxOutput + 0.5);
62 }
63 }
64  
65 /* end class LookUpTable8Interp */
66 }
67 }