corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /* |
2 | * CVS Identifier: |
||
3 | * |
||
4 | * $Id: DataBlk.java,v 1.7 2001/04/15 14:32:05 grosbois Exp $ |
||
5 | * |
||
6 | * Interface: DataBlk |
||
7 | * |
||
8 | * Description: A generic interface to hold 2D blocks of data. |
||
9 | * |
||
10 | * |
||
11 | * |
||
12 | * COPYRIGHT: |
||
13 | * |
||
14 | * This software module was originally developed by Raphaël Grosbois and |
||
15 | * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel |
||
16 | * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David |
||
17 | * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research |
||
18 | * Centre France S.A) in the course of development of the JPEG2000 |
||
19 | * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This |
||
20 | * software module is an implementation of a part of the JPEG 2000 |
||
21 | * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio |
||
22 | * Systems AB and Canon Research Centre France S.A (collectively JJ2000 |
||
23 | * Partners) agree not to assert against ISO/IEC and users of the JPEG |
||
24 | * 2000 Standard (Users) any of their rights under the copyright, not |
||
25 | * including other intellectual property rights, for this software module |
||
26 | * with respect to the usage by ISO/IEC and Users of this software module |
||
27 | * or modifications thereof for use in hardware or software products |
||
28 | * claiming conformance to the JPEG 2000 Standard. Those intending to use |
||
29 | * this software module in hardware or software products are advised that |
||
30 | * their use may infringe existing patents. The original developers of |
||
31 | * this software module, JJ2000 Partners and ISO/IEC assume no liability |
||
32 | * for use of this software module or modifications thereof. No license |
||
33 | * or right to this software module is granted for non JPEG 2000 Standard |
||
34 | * conforming products. JJ2000 Partners have full right to use this |
||
35 | * software module for his/her own purpose, assign or donate this |
||
36 | * software module to any third party and to inhibit third parties from |
||
37 | * using this software module for non JPEG 2000 Standard conforming |
||
38 | * products. This copyright notice must be included in all copies or |
||
39 | * derivative works of this software module. |
||
40 | * |
||
41 | * Copyright (c) 1999/2000 JJ2000 Partners. |
||
42 | * */ |
||
43 | using System; |
||
44 | namespace CSJ2K.j2k.image |
||
45 | { |
||
46 | |||
47 | /// <summary> This is a generic abstract class to store data from a block of an |
||
48 | /// image. This class does not have the notion of components. Therefore, it |
||
49 | /// should be used for data from a single component. Subclasses should |
||
50 | /// implement the different types of storage (<tt>int</tt>, <tt>float</tt>, |
||
51 | /// etc.). |
||
52 | /// |
||
53 | /// <p>The data is always stored in one array, of the type matching the data |
||
54 | /// type (i.e. for 'int' it's an 'int[]'). The data should be stored in the |
||
55 | /// array in standard scan-line order. That is the samples go from the top-left |
||
56 | /// corner of the code-block to the lower-right corner by line and then |
||
57 | /// column.</p> |
||
58 | /// |
||
59 | /// <p>The member variable 'offset' gives the index in the array of the first |
||
60 | /// data element (i.e. the top-left coefficient (ulx,uly)). The member variable |
||
61 | /// 'scanw' gives the width of the scan that is used to store the data, that |
||
62 | /// can be different from the width of the block. Element '(x,y)' of the |
||
63 | /// code-block (i.e. '(ulx,uly)' is the top-left coefficient), will appear at |
||
64 | /// position 'offset+(y-uly)*scanw+(x-ulx)' in the array of data.</p> |
||
65 | /// |
||
66 | /// <p>A block of data can have the <i>progressive</i> attribute set. Data is |
||
67 | /// progressive when it is obtained by successive refinement and the values in |
||
68 | /// this block are approximations of the "final" values. When the final values |
||
69 | /// are returned the progressive attribute must be turned off.</p> |
||
70 | /// |
||
71 | /// <p>The classes <tt>DataBlkInt</tt> and <tt>DataBlkFloat</tt> provide |
||
72 | /// implementations for <tt>int</tt> and <tt>float</tt> types respectively.</p> |
||
73 | /// |
||
74 | /// </summary> |
||
75 | /// <seealso cref="DataBlkInt"> |
||
76 | /// |
||
77 | /// </seealso> |
||
78 | /// <seealso cref="DataBlkFloat"> |
||
79 | /// |
||
80 | /// </seealso> |
||
81 | public abstract class DataBlk |
||
82 | { |
||
83 | /// <summary> Returns the data type of the <tt>DataBlk</tt> object, as defined in |
||
84 | /// this class. |
||
85 | /// |
||
86 | /// </summary> |
||
87 | /// <returns> The data type of the object, as defined in thsi class. |
||
88 | /// |
||
89 | /// </returns> |
||
90 | public abstract int DataType{get;} |
||
91 | //UPGRADE_NOTE: Respective javadoc comments were merged. It should be changed in order to comply with .NET documentation conventions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1199'" |
||
92 | /// <summary> Returns the array containing the data, or null if there is no data. The |
||
93 | /// returned array is of the type returned by <tt>getDataType()</tt> (e.g., |
||
94 | /// for <tt>TYPE_INT</tt>, it is a <tt>int[]</tt>). |
||
95 | /// |
||
96 | /// <p>Each implementing class should provide a type specific equivalent |
||
97 | /// method (e.g., <tt>getDataInt()</tt> in <tt>DataBlkInt</tt>) which |
||
98 | /// returns an array of the correct type explicetely and not through an |
||
99 | /// <tt>Object</tt>.</p> |
||
100 | /// |
||
101 | /// </summary> |
||
102 | /// <returns> The array containing the data, or <tt>null</tt> if there is no |
||
103 | /// data. |
||
104 | /// |
||
105 | /// </returns> |
||
106 | /// <seealso cref="getDataType"> |
||
107 | /// |
||
108 | /// </seealso> |
||
109 | /// <summary> Sets the data array to the specified one. The type of the specified |
||
110 | /// data array must match the one returned by <tt>getDataType()</tt> (e.g., |
||
111 | /// for <tt>TYPE_INT</tt>, it should be a <tt>int[]</tt>). If the wrong |
||
112 | /// type of array is given a <tt>ClassCastException</tt> will be thrown. |
||
113 | /// |
||
114 | /// <p>The size of the array is not necessarily checked for consistency |
||
115 | /// with <tt>w</tt> and <tt>h</tt> or any other fields.</p> |
||
116 | /// |
||
117 | /// <p>Each implementing class should provide a type specific equivalent |
||
118 | /// method (e.g., <tt>setDataInt()</tt> in <tt>DataBlkInt</tt>) which takes |
||
119 | /// an array of the correct type explicetely and not through an |
||
120 | /// <tt>Object</tt>.</p> |
||
121 | /// |
||
122 | /// </summary> |
||
123 | /// <param name="arr">The new data array to use |
||
124 | /// |
||
125 | /// </param> |
||
126 | /// <seealso cref="getDataType"> |
||
127 | /// |
||
128 | /// </seealso> |
||
129 | public abstract System.Object Data{get;set;} |
||
130 | |||
131 | /// <summary>The identifier for the <tt>byte</tt> data type, as signed 8 bits. </summary> |
||
132 | public const int TYPE_BYTE = 0; |
||
133 | |||
134 | /// <summary>The identifier for the <tt>short</tt> data type, as signed 16 bits. </summary> |
||
135 | public const int TYPE_SHORT = 1; |
||
136 | |||
137 | /// <summary>The identifier for the <tt>int</tt> data type, as signed 32 bits. </summary> |
||
138 | public const int TYPE_INT = 3; |
||
139 | |||
140 | /// <summary>The identifier for the <tt>float</tt> data type </summary> |
||
141 | public const int TYPE_FLOAT = 4; |
||
142 | |||
143 | /// <summary>The horizontal coordinate (in pixels) of the upper-left corner of the |
||
144 | /// block of data. This is relative to the component of the image from |
||
145 | /// where this block was filled or is to be filled. |
||
146 | /// </summary> |
||
147 | public int ulx; |
||
148 | |||
149 | /// <summary>The vertical coordinate of the upper-left corner of the block of |
||
150 | /// data. This is relative to the component of the image from where this |
||
151 | /// block was filled or is to be filled. |
||
152 | /// </summary> |
||
153 | public int uly; |
||
154 | |||
155 | /// <summary>The width of the block, in pixels. </summary> |
||
156 | public int w; |
||
157 | |||
158 | /// <summary>The height of the block, in pixels. </summary> |
||
159 | public int h; |
||
160 | |||
161 | /// <summary>The offset in the array of the top-left coefficient </summary> |
||
162 | public int offset; |
||
163 | |||
164 | /// <summary>The width of the scanlines used to store the data in the array </summary> |
||
165 | public int scanw; |
||
166 | |||
167 | /// <summary>The progressive attribute (<tt>false</tt> by default) </summary> |
||
168 | public bool progressive; |
||
169 | |||
170 | /// <summary> Returns the size in bits, given the data type. The data type must be |
||
171 | /// one defined in this class. An <tt>IllegalArgumentException</tt> is |
||
172 | /// thrown if <tt>type</tt> is not defined in this class. |
||
173 | /// |
||
174 | /// </summary> |
||
175 | /// <param name="type">The data type. |
||
176 | /// |
||
177 | /// </param> |
||
178 | /// <returns> The size in bits of the data type. |
||
179 | /// |
||
180 | /// </returns> |
||
181 | public static int getSize(int type) |
||
182 | { |
||
183 | switch (type) |
||
184 | { |
||
185 | |||
186 | case TYPE_BYTE: |
||
187 | return 8; |
||
188 | |||
189 | case TYPE_SHORT: |
||
190 | return 16; |
||
191 | |||
192 | case TYPE_INT: |
||
193 | case TYPE_FLOAT: |
||
194 | return 32; |
||
195 | |||
196 | default: |
||
197 | throw new System.ArgumentException(); |
||
198 | |||
199 | } |
||
200 | } |
||
201 | |||
202 | /// <summary> Returns a string of informations about the DataBlk |
||
203 | /// |
||
204 | /// </summary> |
||
205 | /// <returns> Block dimensions and progressiveness in a string |
||
206 | /// |
||
207 | /// </returns> |
||
208 | public override System.String ToString() |
||
209 | { |
||
210 | System.String typeString = ""; |
||
211 | switch (DataType) |
||
212 | { |
||
213 | |||
214 | case TYPE_BYTE: |
||
215 | typeString = "Unsigned Byte"; |
||
216 | break; |
||
217 | |||
218 | case TYPE_SHORT: |
||
219 | typeString = "Short"; |
||
220 | break; |
||
221 | |||
222 | case TYPE_INT: |
||
223 | typeString = "Integer"; |
||
224 | break; |
||
225 | |||
226 | case TYPE_FLOAT: |
||
227 | typeString = "Float"; |
||
228 | break; |
||
229 | } |
||
230 | |||
231 | return "DataBlk: " + "upper-left(" + ulx + "," + uly + "), width=" + w + ", height=" + h + ", progressive=" + progressive + ", offset=" + offset + ", scanw=" + scanw + ", type=" + typeString; |
||
232 | } |
||
233 | } |
||
234 | } |