corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /// <summary>************************************************************************** |
2 | /// |
||
3 | /// $Id: ChannelDefinitionBox.java,v 1.1 2002/07/25 14:50:46 grosbois Exp $ |
||
4 | /// |
||
5 | /// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650 |
||
6 | /// $Date $ |
||
7 | /// *************************************************************************** |
||
8 | /// </summary> |
||
9 | using System; |
||
10 | using ColorSpaceException = CSJ2K.Color.ColorSpaceException; |
||
11 | using ICCProfile = CSJ2K.Icc.ICCProfile; |
||
12 | using ParameterList = CSJ2K.j2k.util.ParameterList; |
||
13 | using RandomAccessIO = CSJ2K.j2k.io.RandomAccessIO; |
||
14 | namespace CSJ2K.Color.Boxes |
||
15 | { |
||
16 | |||
17 | /// <summary> This class maps the components in the codestream |
||
18 | /// to channels in the image. It models the Component |
||
19 | /// Mapping box in the JP2 header. |
||
20 | /// |
||
21 | /// </summary> |
||
22 | /// <version> 1.0 |
||
23 | /// </version> |
||
24 | /// <author> Bruce A. Kern |
||
25 | /// </author> |
||
26 | public sealed class ChannelDefinitionBox:JP2Box |
||
27 | { |
||
28 | public int NDefs |
||
29 | { |
||
30 | /* Return the number of channel definitions. */ |
||
31 | |||
32 | get |
||
33 | { |
||
34 | return ndefs; |
||
35 | } |
||
36 | |||
37 | } |
||
38 | |||
39 | private int ndefs; |
||
40 | private System.Collections.Hashtable definitions = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable()); |
||
41 | |||
42 | /// <summary> Construct a ChannelDefinitionBox from an input image.</summary> |
||
43 | /// <param name="in">RandomAccessIO jp2 image |
||
44 | /// </param> |
||
45 | /// <param name="boxStart">offset to the start of the box in the image |
||
46 | /// </param> |
||
47 | /// <exception cref="IOException,">ColorSpaceException |
||
48 | /// </exception> |
||
49 | public ChannelDefinitionBox(RandomAccessIO in_Renamed, int boxStart):base(in_Renamed, boxStart) |
||
50 | { |
||
51 | readBox(); |
||
52 | } |
||
53 | |||
54 | /// <summary>Analyze the box content. </summary> |
||
55 | private void readBox() |
||
56 | { |
||
57 | |||
58 | byte[] bfr = new byte[8]; |
||
59 | |||
60 | in_Renamed.seek(dataStart); |
||
61 | in_Renamed.readFully(bfr, 0, 2); |
||
62 | ndefs = ICCProfile.getShort(bfr, 0) & 0x0000ffff; |
||
63 | |||
64 | int offset = dataStart + 2; |
||
65 | in_Renamed.seek(offset); |
||
66 | for (int i = 0; i < ndefs; ++i) |
||
67 | { |
||
68 | in_Renamed.readFully(bfr, 0, 6); |
||
69 | int channel = ICCProfile.getShort(bfr, 0); |
||
70 | int[] channel_def = new int[3]; |
||
71 | channel_def[0] = getCn(bfr); |
||
72 | channel_def[1] = getTyp(bfr); |
||
73 | channel_def[2] = getAsoc(bfr); |
||
74 | definitions[(System.Int32) channel_def[0]] = channel_def; |
||
75 | } |
||
76 | } |
||
77 | |||
78 | /* Return the channel association. */ |
||
79 | public int getCn(int asoc) |
||
80 | { |
||
81 | System.Collections.IEnumerator keys = definitions.Keys.GetEnumerator(); |
||
82 | //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'" |
||
83 | while (keys.MoveNext()) |
||
84 | { |
||
85 | //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'" |
||
86 | int[] bfr = (int[]) definitions[keys.Current]; |
||
87 | if (asoc == getAsoc(bfr)) |
||
88 | return getCn(bfr); |
||
89 | } |
||
90 | return asoc; |
||
91 | } |
||
92 | |||
93 | /* Return the channel type. */ |
||
94 | public int getTyp(int channel) |
||
95 | { |
||
96 | int[] bfr = (int[]) definitions[(System.Int32) channel]; |
||
97 | return getTyp(bfr); |
||
98 | } |
||
99 | |||
100 | /* Return the associated channel of the association. */ |
||
101 | public int getAsoc(int channel) |
||
102 | { |
||
103 | int[] bfr = (int[]) definitions[(System.Int32) channel]; |
||
104 | return getAsoc(bfr); |
||
105 | } |
||
106 | |||
107 | |||
108 | /// <summary>Return a suitable String representation of the class instance. </summary> |
||
109 | public override System.String ToString() |
||
110 | { |
||
111 | System.Text.StringBuilder rep = new System.Text.StringBuilder("[ChannelDefinitionBox ").Append(eol).Append(" "); |
||
112 | rep.Append("ndefs= ").Append(System.Convert.ToString(ndefs)); |
||
113 | |||
114 | System.Collections.IEnumerator keys = definitions.Keys.GetEnumerator(); |
||
115 | //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'" |
||
116 | while (keys.MoveNext()) |
||
117 | { |
||
118 | //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'" |
||
119 | int[] bfr = (int[]) definitions[keys.Current]; |
||
120 | rep.Append(eol).Append(" ").Append("Cn= ").Append(System.Convert.ToString(getCn(bfr))).Append(", ").Append("Typ= ").Append(System.Convert.ToString(getTyp(bfr))).Append(", ").Append("Asoc= ").Append(System.Convert.ToString(getAsoc(bfr))); |
||
121 | } |
||
122 | |||
123 | rep.Append("]"); |
||
124 | return rep.ToString(); |
||
125 | } |
||
126 | |||
127 | /// <summary>Return the channel from the record.</summary> |
||
128 | private int getCn(byte[] bfr) |
||
129 | { |
||
130 | return ICCProfile.getShort(bfr, 0); |
||
131 | } |
||
132 | |||
133 | /// <summary>Return the channel type from the record.</summary> |
||
134 | private int getTyp(byte[] bfr) |
||
135 | { |
||
136 | return ICCProfile.getShort(bfr, 2); |
||
137 | } |
||
138 | |||
139 | /// <summary>Return the associated channel from the record.</summary> |
||
140 | private int getAsoc(byte[] bfr) |
||
141 | { |
||
142 | return ICCProfile.getShort(bfr, 4); |
||
143 | } |
||
144 | |||
145 | private int getCn(int[] bfr) |
||
146 | { |
||
147 | return bfr[0]; |
||
148 | } |
||
149 | |||
150 | private int getTyp(int[] bfr) |
||
151 | { |
||
152 | return bfr[1]; |
||
153 | } |
||
154 | |||
155 | private int getAsoc(int[] bfr) |
||
156 | { |
||
157 | return bfr[2]; |
||
158 | } |
||
159 | |||
160 | /* end class ChannelDefinitionBox */ |
||
161 | static ChannelDefinitionBox() |
||
162 | { |
||
163 | { |
||
164 | type = 0x63646566; |
||
165 | } |
||
166 | } |
||
167 | } |
||
168 | } |