corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /// <summary>************************************************************************** |
2 | /// |
||
3 | /// $Id: ComponentMappingBox.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 ComponentMappingBox:JP2Box |
||
27 | { |
||
28 | public int NChannels |
||
29 | { |
||
30 | /* Return the number of mapped channels. */ |
||
31 | |||
32 | get |
||
33 | { |
||
34 | return nChannels; |
||
35 | } |
||
36 | |||
37 | } |
||
38 | |||
39 | private int nChannels; |
||
40 | private System.Collections.ArrayList map = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10)); |
||
41 | |||
42 | /// <summary> Construct a ComponentMappingBox 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 ComponentMappingBox(RandomAccessIO in_Renamed, int boxStart):base(in_Renamed, boxStart) |
||
50 | { |
||
51 | readBox(); |
||
52 | } |
||
53 | |||
54 | /// <summary>Analyze the box content. </summary> |
||
55 | internal void readBox() |
||
56 | { |
||
57 | nChannels = (boxEnd - dataStart) / 4; |
||
58 | in_Renamed.seek(dataStart); |
||
59 | for (int offset = dataStart; offset < boxEnd; offset += 4) |
||
60 | { |
||
61 | byte[] mapping = new byte[4]; |
||
62 | in_Renamed.readFully(mapping, 0, 4); |
||
63 | map.Add(mapping); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | /* Return the component mapped to the channel. */ |
||
68 | public int getCMP(int channel) |
||
69 | { |
||
70 | byte[] mapping = (byte[]) map[channel]; |
||
71 | return ICCProfile.getShort(mapping, 0) & 0x0000ffff; |
||
72 | } |
||
73 | |||
74 | /// <summary>Return the channel type. </summary> |
||
75 | public short getMTYP(int channel) |
||
76 | { |
||
77 | byte[] mapping = (byte[]) map[channel]; |
||
78 | return (short) (mapping[2] & 0x00ff); |
||
79 | } |
||
80 | |||
81 | /// <summary>Return the palette index for the channel. </summary> |
||
82 | public short getPCOL(int channel) |
||
83 | { |
||
84 | byte[] mapping = (byte[]) map[channel]; |
||
85 | return (short) (mapping[3] & 0x000ff); |
||
86 | } |
||
87 | |||
88 | /// <summary>Return a suitable String representation of the class instance. </summary> |
||
89 | public override System.String ToString() |
||
90 | { |
||
91 | System.Text.StringBuilder rep = new System.Text.StringBuilder("[ComponentMappingBox ").Append(" "); |
||
92 | rep.Append("nChannels= ").Append(System.Convert.ToString(nChannels)); |
||
93 | System.Collections.IEnumerator Enum = map.GetEnumerator(); |
||
94 | //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'" |
||
95 | while (Enum.MoveNext()) |
||
96 | { |
||
97 | //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'" |
||
98 | byte[] bfr = (byte[]) Enum.Current; |
||
99 | rep.Append(eol).Append(" ").Append("CMP= ").Append(System.Convert.ToString(getCMP(bfr))).Append(", "); |
||
100 | rep.Append("MTYP= ").Append(System.Convert.ToString(getMTYP(bfr))).Append(", "); |
||
101 | rep.Append("PCOL= ").Append(System.Convert.ToString(getPCOL(bfr))); |
||
102 | } |
||
103 | rep.Append("]"); |
||
104 | return rep.ToString(); |
||
105 | } |
||
106 | |||
107 | private int getCMP(byte[] mapping) |
||
108 | { |
||
109 | return ICCProfile.getShort(mapping, 0) & 0x0000ffff; |
||
110 | } |
||
111 | |||
112 | private short getMTYP(byte[] mapping) |
||
113 | { |
||
114 | return (short) (mapping[2] & 0x00ff); |
||
115 | } |
||
116 | |||
117 | private short getPCOL(byte[] mapping) |
||
118 | { |
||
119 | return (short) (mapping[3] & 0x000ff); |
||
120 | } |
||
121 | |||
122 | /* end class ComponentMappingBox */ |
||
123 | static ComponentMappingBox() |
||
124 | { |
||
125 | { |
||
126 | type = 0x636d6170; |
||
127 | } |
||
128 | } |
||
129 | } |
||
130 | } |