corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /// <summary>**************************************************************************
2 ///
3 /// $Id: LookUpTableFPInterp.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 /// <summary> An interpolated floating point lut
15 ///
16 /// </summary>
17 /// <version> 1.0
18 /// </version>
19 /// <author> Bruce A.Kern
20 /// </author>
21 public class LookUpTableFPInterp:LookUpTableFP
22 {
23  
24 /// <summary> Create an abbreviated string representation of a 16 bit lut.</summary>
25 /// <returns> the lut as a String
26 /// </returns>
27 public override System.String ToString()
28 {
29 System.Text.StringBuilder rep = new System.Text.StringBuilder("[LookUpTable32 ").Append(" nentries= " + lut.Length);
30 return rep.Append("]").ToString();
31 }
32  
33 /// <summary> Construct the lut from the curve data</summary>
34 /// <oaram> curve the data </oaram>
35 /// <oaram> dwNumInput the lut size </oaram>
36 public LookUpTableFPInterp(ICCCurveType curve, int dwNumInput):base(curve, dwNumInput)
37 {
38  
39 int dwLowIndex, dwHighIndex; // Indices of interpolation points
40 double dfLowIndex, dfHighIndex; // FP indices of interpolation points
41 double dfTargetIndex; // Target index into interpolation table
42 double dfRatio; // Ratio of LUT input points to curve values
43 double dfLow, dfHigh; // Interpolation values
44  
45 dfRatio = (double) (curve.nEntries - 1) / (double) (dwNumInput - 1);
46  
47 for (int i = 0; i < dwNumInput; i++)
48 {
49 dfTargetIndex = (double) i * dfRatio;
50 dfLowIndex = System.Math.Floor(dfTargetIndex);
51 //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'"
52 dwLowIndex = (int) dfLowIndex;
53 dfHighIndex = System.Math.Ceiling(dfTargetIndex);
54 //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'"
55 dwHighIndex = (int) dfHighIndex;
56 if (dwLowIndex == dwHighIndex)
57 {
58 //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'"
59 lut[i] = (float) ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
60 }
61 else
62 {
63 dfLow = ICCCurveType.CurveToDouble(curve.entry(dwLowIndex));
64 dfHigh = ICCCurveType.CurveToDouble(curve.entry(dwHighIndex));
65 //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'"
66 lut[i] = (float) (dfLow + (dfHigh - dfLow) * (dfTargetIndex - dfLowIndex));
67 }
68 }
69 }
70  
71 /* end class LookUpTableFPInterp */
72 }
73 }