corrade-vassal – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * CVS identifier:
3 *
4 * $Id: ImgDataAdapter.java,v 1.8 2001/09/14 09:17:23 grosbois Exp $
5 *
6 * Class: ImgDataAdapter
7 *
8 * Description: A default implementation of the ImgData
9 * interface that has an ImgData source and just
10 * returns the values of the source.
11 *
12 *
13 *
14 * COPYRIGHT:
15 *
16 * This software module was originally developed by Raphaël Grosbois and
17 * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
18 * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
19 * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
20 * Centre France S.A) in the course of development of the JPEG2000
21 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
22 * software module is an implementation of a part of the JPEG 2000
23 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
24 * Systems AB and Canon Research Centre France S.A (collectively JJ2000
25 * Partners) agree not to assert against ISO/IEC and users of the JPEG
26 * 2000 Standard (Users) any of their rights under the copyright, not
27 * including other intellectual property rights, for this software module
28 * with respect to the usage by ISO/IEC and Users of this software module
29 * or modifications thereof for use in hardware or software products
30 * claiming conformance to the JPEG 2000 Standard. Those intending to use
31 * this software module in hardware or software products are advised that
32 * their use may infringe existing patents. The original developers of
33 * this software module, JJ2000 Partners and ISO/IEC assume no liability
34 * for use of this software module or modifications thereof. No license
35 * or right to this software module is granted for non JPEG 2000 Standard
36 * conforming products. JJ2000 Partners have full right to use this
37 * software module for his/her own purpose, assign or donate this
38 * software module to any third party and to inhibit third parties from
39 * using this software module for non JPEG 2000 Standard conforming
40 * products. This copyright notice must be included in all copies or
41 * derivative works of this software module.
42 *
43 * Copyright (c) 1999/2000 JJ2000 Partners.
44 * */
45 using System;
46 namespace CSJ2K.j2k.image
47 {
48  
49 /// <summary> This class provides a default implementation of the methods in the
50 /// 'ImgData' interface. The default implementation is just to return the value
51 /// of the source, where the source is another 'ImgData' object.
52 ///
53 /// <p>This abstract class can be used to facilitate the development of other
54 /// classes that implement 'ImgData'. For example a YCbCr color transform can
55 /// inherit from this class and all the trivial methods do not have to be
56 /// re-implemented.</p>
57 ///
58 /// <p>If the default implementation of a method provided in this class does
59 /// not suit a particular implementation of the 'ImgData' interface, the method
60 /// can be overridden to implement the proper behavior.</p>
61 ///
62 /// </summary>
63 /// <seealso cref="ImgData">
64 ///
65 /// </seealso>
66 public abstract class ImgDataAdapter : ImgData
67 {
68 /// <summary> Returns the overall width of the current tile in pixels. This is the
69 /// tile's width without accounting for any component subsampling. This is
70 /// also referred as the reference grid width in the current tile.
71 ///
72 /// <p>This default implementation returns the value of the source.</p>
73 ///
74 /// </summary>
75 /// <returns> The total current tile's width in pixels.
76 ///
77 /// </returns>
78 virtual public int TileWidth
79 {
80 get
81 {
82 return imgdatasrc.TileWidth;
83 }
84  
85 }
86 /// <summary> Returns the overall height of the current tile in pixels. This is the
87 /// tile's height without accounting for any component subsampling. This is
88 /// also referred as the reference grid height in the current tile.
89 ///
90 /// <p>This default implementation returns the value of the source.</p>
91 ///
92 /// </summary>
93 /// <returns> The total current tile's height in pixels.
94 ///
95 /// </returns>
96 virtual public int TileHeight
97 {
98 get
99 {
100 return imgdatasrc.TileHeight;
101 }
102  
103 }
104 /// <summary>Returns the nominal tiles width </summary>
105 virtual public int NomTileWidth
106 {
107 get
108 {
109 return imgdatasrc.NomTileWidth;
110 }
111  
112 }
113 /// <summary>Returns the nominal tiles height </summary>
114 virtual public int NomTileHeight
115 {
116 get
117 {
118 return imgdatasrc.NomTileHeight;
119 }
120  
121 }
122 /// <summary> Returns the overall width of the image in pixels. This is the image's
123 /// width without accounting for any component subsampling or tiling.
124 ///
125 /// <p>This default implementation returns the value of the source.</p>
126 ///
127 /// </summary>
128 /// <returns> The total image's width in pixels.
129 ///
130 /// </returns>
131 virtual public int ImgWidth
132 {
133 get
134 {
135 return imgdatasrc.ImgWidth;
136 }
137  
138 }
139 /// <summary> Returns the overall height of the image in pixels. This is the image's
140 /// height without accounting for any component subsampling or tiling.
141 ///
142 /// <p>This default implementation returns the value of the source.</p>
143 ///
144 /// </summary>
145 /// <returns> The total image's height in pixels.
146 ///
147 /// </returns>
148 virtual public int ImgHeight
149 {
150 get
151 {
152 return imgdatasrc.ImgHeight;
153 }
154  
155 }
156 /// <summary> Returns the number of components in the image.
157 ///
158 /// <p>This default implementation returns the value of the source.</p>
159 ///
160 /// </summary>
161 /// <returns> The number of components in the image.
162 ///
163 /// </returns>
164 virtual public int NumComps
165 {
166 get
167 {
168 return imgdatasrc.NumComps;
169 }
170  
171 }
172 /// <summary> Returns the index of the current tile, relative to a standard scan-line
173 /// order.
174 ///
175 /// <p>This default implementation returns the value of the source.</p>
176 ///
177 /// </summary>
178 /// <returns> The current tile's index (starts at 0).
179 ///
180 /// </returns>
181 virtual public int TileIdx
182 {
183 get
184 {
185 return imgdatasrc.TileIdx;
186 }
187  
188 }
189 /// <summary>Returns the horizontal tile partition offset in the reference grid </summary>
190 virtual public int TilePartULX
191 {
192 get
193 {
194 return imgdatasrc.TilePartULX;
195 }
196  
197 }
198 /// <summary>Returns the vertical tile offset in the reference grid </summary>
199 virtual public int TilePartULY
200 {
201 get
202 {
203 return imgdatasrc.TilePartULY;
204 }
205  
206 }
207 /// <summary> Returns the horizontal coordinate of the image origin, the top-left
208 /// corner, in the canvas system, on the reference grid.
209 ///
210 /// <p>This default implementation returns the value of the source.</p>
211 ///
212 /// </summary>
213 /// <returns> The horizontal coordinate of the image origin in the canvas
214 /// system, on the reference grid.
215 ///
216 /// </returns>
217 virtual public int ImgULX
218 {
219 get
220 {
221 return imgdatasrc.ImgULX;
222 }
223  
224 }
225 /// <summary> Returns the vertical coordinate of the image origin, the top-left
226 /// corner, in the canvas system, on the reference grid.
227 ///
228 /// <p>This default implementation returns the value of the source.</p>
229 ///
230 /// </summary>
231 /// <returns> The vertical coordinate of the image origin in the canvas
232 /// system, on the reference grid.
233 ///
234 /// </returns>
235 virtual public int ImgULY
236 {
237 get
238 {
239 return imgdatasrc.ImgULY;
240 }
241  
242 }
243  
244 /// <summary>Index of the current tile </summary>
245 protected internal int tIdx = 0;
246  
247 /// <summary>The ImgData source </summary>
248 protected internal ImgData imgdatasrc;
249  
250 /// <summary> Instantiates the ImgDataAdapter object specifying the ImgData source.
251 ///
252 /// </summary>
253 /// <param name="src">From where to obtain all the ImgData values.
254 ///
255 /// </param>
256 protected internal ImgDataAdapter(ImgData src)
257 {
258 imgdatasrc = src;
259 }
260  
261 /// <summary> Returns the component subsampling factor in the horizontal direction,
262 /// for the specified component. This is, approximately, the ratio of
263 /// dimensions between the reference grid and the component itself, see the
264 /// 'ImgData' interface desription for details.
265 ///
266 /// <p>This default implementation returns the value of the source.</p>
267 ///
268 /// </summary>
269 /// <param name="c">The index of the component (between 0 and N-1)
270 ///
271 /// </param>
272 /// <returns> The horizontal subsampling factor of component 'c'
273 ///
274 /// </returns>
275 /// <seealso cref="ImgData">
276 ///
277 /// </seealso>
278 public virtual int getCompSubsX(int c)
279 {
280 return imgdatasrc.getCompSubsX(c);
281 }
282  
283 /// <summary> Returns the component subsampling factor in the vertical direction, for
284 /// the specified component. This is, approximately, the ratio of
285 /// dimensions between the reference grid and the component itself, see the
286 /// 'ImgData' interface desription for details.
287 ///
288 /// <p>This default implementation returns the value of the source.</p>
289 ///
290 /// </summary>
291 /// <param name="c">The index of the component (between 0 and N-1)
292 ///
293 /// </param>
294 /// <returns> The vertical subsampling factor of component 'c'
295 ///
296 /// </returns>
297 /// <seealso cref="ImgData">
298 ///
299 /// </seealso>
300 public virtual int getCompSubsY(int c)
301 {
302 return imgdatasrc.getCompSubsY(c);
303 }
304  
305 /// <summary> Returns the width in pixels of the specified tile-component
306 /// tile.
307 ///
308 /// <p>This default implementation returns the value of the source.</p>
309 ///
310 /// </summary>
311 /// <param name="t">Tile index
312 ///
313 /// </param>
314 /// <param name="c">The index of the component, from 0 to N-1.
315 ///
316 /// </param>
317 /// <returns> The width in pixels of component <tt>c</tt> in tile<tt>t</tt>.
318 ///
319 /// </returns>
320 public virtual int getTileCompWidth(int t, int c)
321 {
322 return imgdatasrc.getTileCompWidth(t, c);
323 }
324  
325 /// <summary> Returns the height in pixels of the specified tile-component.
326 ///
327 /// <p>This default implementation returns the value of the source.</p>
328 ///
329 /// </summary>
330 /// <param name="t">The tile index.
331 ///
332 /// </param>
333 /// <param name="c">The index of the component, from 0 to N-1.
334 ///
335 /// </param>
336 /// <returns> The height in pixels of component <tt>c</tt> in tile
337 /// <tt>t</tt>.
338 ///
339 /// </returns>
340 public virtual int getTileCompHeight(int t, int c)
341 {
342 return imgdatasrc.getTileCompHeight(t, c);
343 }
344  
345 /// <summary> Returns the width in pixels of the specified component in the overall
346 /// image.
347 ///
348 /// <p>This default implementation returns the value of the source.</p>
349 ///
350 /// </summary>
351 /// <param name="c">The index of the component, from 0 to N-1.
352 ///
353 /// </param>
354 /// <returns> The width in pixels of component <tt>c</tt> in the overall
355 /// image.
356 ///
357 /// </returns>
358 public virtual int getCompImgWidth(int c)
359 {
360 return imgdatasrc.getCompImgWidth(c);
361 }
362  
363 /// <summary> Returns the height in pixels of the specified component in the overall
364 /// image.
365 ///
366 /// <p>This default implementation returns the value of the source.</p>
367 ///
368 /// </summary>
369 /// <param name="c">The index of the component, from 0 to N-1.
370 ///
371 /// </param>
372 /// <returns> The height in pixels of component <tt>c</tt> in the overall
373 /// image.
374 ///
375 /// </returns>
376 public virtual int getCompImgHeight(int c)
377 {
378 return imgdatasrc.getCompImgHeight(c);
379 }
380  
381 /// <summary> Returns the number of bits, referred to as the "range bits",
382 /// corresponding to the nominal range of the image data in the specified
383 /// component. If this number is <i>n</b> then for unsigned data the
384 /// nominal range is between 0 and 2^b-1, and for signed data it is between
385 /// -2^(b-1) and 2^(b-1)-1. In the case of transformed data which is not in
386 /// the image domain (e.g., wavelet coefficients), this method returns the
387 /// "range bits" of the image data that generated the coefficients.
388 ///
389 /// <p>This default implementation returns the value of the source.</p>
390 ///
391 /// </summary>
392 /// <param name="c">The index of the component.
393 ///
394 /// </param>
395 /// <returns> The number of bits corresponding to the nominal range of the
396 /// image data (in the image domain).
397 ///
398 /// </returns>
399 public virtual int getNomRangeBits(int c)
400 {
401 return imgdatasrc.getNomRangeBits(c);
402 }
403  
404 /// <summary> Changes the current tile, given the new indexes. An
405 /// IllegalArgumentException is thrown if the indexes do not correspond to
406 /// a valid tile.
407 ///
408 /// <p>This default implementation just changes the tile in the source.</p>
409 ///
410 /// </summary>
411 /// <param name="x">The horizontal index of the tile.
412 ///
413 /// </param>
414 /// <param name="y">The vertical index of the new tile.
415 ///
416 /// </param>
417 public virtual void setTile(int x, int y)
418 {
419 imgdatasrc.setTile(x, y);
420 tIdx = TileIdx;
421 }
422  
423 /// <summary> Advances to the next tile, in standard scan-line order (by rows then
424 /// columns). An NoNextElementException is thrown if the current tile is
425 /// the last one (i.e. there is no next tile).
426 ///
427 /// <p>This default implementation just advances to the next tile in the
428 /// source.</p>
429 ///
430 /// </summary>
431 public virtual void nextTile()
432 {
433 imgdatasrc.nextTile();
434 tIdx = TileIdx;
435 }
436  
437 /// <summary> Returns the indexes of the current tile. These are the horizontal and
438 /// vertical indexes of the current tile.
439 ///
440 /// <p>This default implementation returns the value of the source.</p>
441 ///
442 /// </summary>
443 /// <param name="co">If not null this object is used to return the information. If
444 /// null a new one is created and returned.
445 ///
446 /// </param>
447 /// <returns> The current tile's indexes (vertical and horizontal indexes).
448 ///
449 /// </returns>
450 public virtual Coord getTile(Coord co)
451 {
452 return imgdatasrc.getTile(co);
453 }
454  
455 /// <summary> Returns the horizontal coordinate of the upper-left corner of the
456 /// specified component in the current tile.
457 ///
458 /// <p>This default implementation returns the value of the source.</p>
459 ///
460 /// </summary>
461 /// <param name="c">The component index.
462 ///
463 /// </param>
464 public virtual int getCompULX(int c)
465 {
466 return imgdatasrc.getCompULX(c);
467 }
468  
469 /// <summary> Returns the vertical coordinate of the upper-left corner of the
470 /// specified component in the current tile.
471 ///
472 /// <p>This default implementation returns the value of the source.</p>
473 ///
474 /// </summary>
475 /// <param name="c">The component index.
476 ///
477 /// </param>
478 public virtual int getCompULY(int c)
479 {
480 return imgdatasrc.getCompULY(c);
481 }
482  
483 /// <summary> Returns the number of tiles in the horizontal and vertical directions.
484 ///
485 /// <p>This default implementation returns the value of the source.</p>
486 ///
487 /// </summary>
488 /// <param name="co">If not null this object is used to return the information. If
489 /// null a new one is created and returned.
490 ///
491 /// </param>
492 /// <returns> The number of tiles in the horizontal (Coord.x) and vertical
493 /// (Coord.y) directions.
494 ///
495 /// </returns>
496 public virtual Coord getNumTiles(Coord co)
497 {
498 return imgdatasrc.getNumTiles(co);
499 }
500  
501 /// <summary> Returns the total number of tiles in the image.
502 ///
503 /// <p>This default implementation returns the value of the source.</p>
504 ///
505 /// </summary>
506 /// <returns> The total number of tiles in the image.
507 ///
508 /// </returns>
509 public virtual int getNumTiles()
510 {
511 return imgdatasrc.getNumTiles();
512 }
513 }
514 }