corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /// <summary>**************************************************************************
2 ///
3 /// $Id: ChannelDefinitionMapper.java,v 1.2 2002/08/08 14:06:53 grosbois Exp $
4 ///
5 /// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650
6 /// $Date $
7 /// ***************************************************************************
8 /// </summary>
9 using System;
10 using CSJ2K.j2k.image;
11 using CSJ2K.j2k.util;
12 namespace CSJ2K.Color
13 {
14  
15 /// <summary> This class is responsible for the mapping between
16 /// requested components and image channels.
17 ///
18 /// </summary>
19 /// <seealso cref="jj2000.j2k.colorspace.ColorSpace">
20 /// </seealso>
21 /// <version> 1.0
22 /// </version>
23 /// <author> Bruce A. Kern
24 /// </author>
25 public class ChannelDefinitionMapper:ColorSpaceMapper
26 {
27 /// <summary> Factory method for creating instances of this class.</summary>
28 /// <param name="src">-- source of image data
29 /// </param>
30 /// <param name="csMap">-- provides colorspace info
31 /// </param>
32 /// <returns> ChannelDefinitionMapper instance
33 /// </returns>
34 /// <exception cref="ColorSpaceException">
35 /// </exception>
36 public static new BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap)
37 {
38  
39 return new ChannelDefinitionMapper(src, csMap);
40 }
41  
42 /// <summary> Ctor which creates an ICCProfile for the image and initializes
43 /// all data objects (input, working, and output).
44 ///
45 /// </summary>
46 /// <param name="src">-- Source of image data
47 /// </param>
48 /// <param name="csm">-- provides colorspace info
49 /// </param>
50 protected internal ChannelDefinitionMapper(BlkImgDataSrc src, ColorSpace csMap):base(src, csMap)
51 {
52 /* end ChannelDefinitionMapper ctor */
53 }
54  
55  
56 /// <summary> Returns, in the blk argument, a block of image data containing the
57 /// specifed rectangular area, in the specified component. The data is
58 /// returned, as a copy of the internal data, therefore the returned data
59 /// can be modified "in place".
60 ///
61 /// <P>The rectangular area to return is specified by the 'ulx', 'uly', 'w'
62 /// and 'h' members of the 'blk' argument, relative to the current
63 /// tile. These members are not modified by this method. The 'offset' of
64 /// the returned data is 0, and the 'scanw' is the same as the block's
65 /// width. See the 'DataBlk' class.
66 ///
67 /// <P>If the data array in 'blk' is 'null', then a new one is created. If
68 /// the data array is not 'null' then it is reused, and it must be large
69 /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
70 /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
71 ///
72 /// <P>The returned data has its 'progressive' attribute set to that of the
73 /// input data.
74 ///
75 /// </summary>
76 /// <param name="blk">Its coordinates and dimensions specify the area to
77 /// return. If it contains a non-null data array, then it must have the
78 /// correct dimensions. If it contains a null data array a new one is
79 /// created. The fields in this object are modified to return the data.
80 ///
81 /// </param>
82 /// <param name="c">The index of the component from which to get the data. Only 0
83 /// and 3 are valid.
84 ///
85 /// </param>
86 /// <returns> The requested DataBlk
87 ///
88 /// </returns>
89 /// <seealso cref="getInternCompData">
90 ///
91 /// </seealso>
92 public override DataBlk getCompData(DataBlk out_Renamed, int c)
93 {
94 return src.getCompData(out_Renamed, csMap.getChannelDefinition(c));
95 }
96  
97 /// <summary> Returns, in the blk argument, a block of image data containing the
98 /// specifed rectangular area, in the specified component. The data is
99 /// returned, as a copy of the internal data, therefore the returned data
100 /// can be modified "in place".
101 ///
102 /// <P>The rectangular area to return is specified by the 'ulx', 'uly', 'w'
103 /// and 'h' members of the 'blk' argument, relative to the current
104 /// tile. These members are not modified by this method. The 'offset' of
105 /// the returned data is 0, and the 'scanw' is the same as the block's
106 /// width. See the 'DataBlk' class.
107 ///
108 /// <P>This method, in general, is less efficient than the
109 /// 'getInternCompData()' method since, in general, it copies the
110 /// data. However if the array of returned data is to be modified by the
111 /// caller then this method is preferable.
112 ///
113 /// <P>If the data array in 'blk' is 'null', then a new one is created. If
114 /// the data array is not 'null' then it is reused, and it must be large
115 /// enough to contain the block's data. Otherwise an 'ArrayStoreException'
116 /// or an 'IndexOutOfBoundsException' is thrown by the Java system.
117 ///
118 /// <P>The returned data may have its 'progressive' attribute set. In this
119 /// case the returned data is only an approximation of the "final" data.
120 ///
121 /// </summary>
122 /// <param name="blk">Its coordinates and dimensions specify the area to return,
123 /// relative to the current tile. If it contains a non-null data array,
124 /// then it must be large enough. If it contains a null data array a new
125 /// one is created. Some fields in this object are modified to return the
126 /// data.
127 ///
128 /// </param>
129 /// <param name="c">The index of the component from which to get the data.
130 ///
131 /// </param>
132 /// <seealso cref="getCompData">
133 ///
134 /// </seealso>
135 public override DataBlk getInternCompData(DataBlk out_Renamed, int c)
136 {
137 return src.getInternCompData(out_Renamed, csMap.getChannelDefinition(c));
138 }
139  
140 /// <summary> Returns the number of bits, referred to as the "range bits",
141 /// corresponding to the nominal range of the data in the specified
142 /// component. If this number is <i>b</b> then for unsigned data the
143 /// nominal range is between 0 and 2^b-1, and for signed data it is between
144 /// -2^(b-1) and 2^(b-1)-1. For floating point data this value is not
145 /// applicable.
146 ///
147 /// </summary>
148 /// <param name="c">The index of the component.
149 ///
150 /// </param>
151 /// <returns> The number of bits corresponding to the nominal range of the
152 /// data. Fro floating-point data this value is not applicable and the
153 /// return value is undefined.
154 /// </returns>
155 public override int getFixedPoint(int c)
156 {
157 return src.getFixedPoint(csMap.getChannelDefinition(c));
158 }
159  
160 public override int getNomRangeBits(int c)
161 {
162 return src.getNomRangeBits(csMap.getChannelDefinition(c));
163 }
164  
165 public override int getCompImgHeight(int c)
166 {
167 return src.getCompImgHeight(csMap.getChannelDefinition(c));
168 }
169  
170 public override int getCompImgWidth(int c)
171 {
172 return src.getCompImgWidth(csMap.getChannelDefinition(c));
173 }
174  
175 public override int getCompSubsX(int c)
176 {
177 return src.getCompSubsX(csMap.getChannelDefinition(c));
178 }
179  
180 public override int getCompSubsY(int c)
181 {
182 return src.getCompSubsY(csMap.getChannelDefinition(c));
183 }
184  
185 public override int getCompULX(int c)
186 {
187 return src.getCompULX(csMap.getChannelDefinition(c));
188 }
189  
190 public override int getCompULY(int c)
191 {
192 return src.getCompULY(csMap.getChannelDefinition(c));
193 }
194  
195 public override int getTileCompHeight(int t, int c)
196 {
197 return src.getTileCompHeight(t, csMap.getChannelDefinition(c));
198 }
199  
200 public override int getTileCompWidth(int t, int c)
201 {
202 return src.getTileCompWidth(t, csMap.getChannelDefinition(c));
203 }
204  
205 public override System.String ToString()
206 {
207 int i;
208 System.Text.StringBuilder rep = new System.Text.StringBuilder("[ChannelDefinitionMapper nchannels= ").Append(ncomps);
209  
210 for (i = 0; i < ncomps; ++i)
211 {
212 rep.Append(eol).Append(" component[").Append(i).Append("] mapped to channel[").Append(csMap.getChannelDefinition(i)).Append("]");
213 }
214  
215 return rep.Append("]").ToString();
216 }
217  
218 /* end class ChannelDefinitionMapper */
219 }
220 }