corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /// <summary>************************************************************************** |
2 | /// |
||
3 | /// $Id: SYccColorSpaceMapper.java,v 1.1 2002/07/25 14:52:01 grosbois Exp $ |
||
4 | /// |
||
5 | /// Copyright Eastman Kodak Company, 343 State Street, Rochester, NY 14650 |
||
6 | /// $Date $ |
||
7 | /// *************************************************************************** |
||
8 | /// </summary> |
||
9 | using System; |
||
10 | using ParameterList = CSJ2K.j2k.util.ParameterList; |
||
11 | using BlkImgDataSrc = CSJ2K.j2k.image.BlkImgDataSrc; |
||
12 | using DataBlk = CSJ2K.j2k.image.DataBlk; |
||
13 | using DataBlkInt = CSJ2K.j2k.image.DataBlkInt; |
||
14 | using DataBlkFloat = CSJ2K.j2k.image.DataBlkFloat; |
||
15 | using ImgDataAdapter = CSJ2K.j2k.image.ImgDataAdapter; |
||
16 | using FacilityManager = CSJ2K.j2k.util.FacilityManager; |
||
17 | using MsgLogger = CSJ2K.j2k.util.MsgLogger; |
||
18 | namespace CSJ2K.Color |
||
19 | { |
||
20 | |||
21 | |||
22 | /// <summary> This decodes maps which are defined in the e-sRGB |
||
23 | /// colorspace into the sRGB colorspace. |
||
24 | /// |
||
25 | /// </summary> |
||
26 | /// <seealso cref="jj2000.j2k.colorspace.ColorSpace"> |
||
27 | /// </seealso> |
||
28 | /// <version> 1.0 |
||
29 | /// </version> |
||
30 | /// <author> Jason S. Clary |
||
31 | /// </author> |
||
32 | public class EsRgbColorSpaceMapper : ColorSpaceMapper |
||
33 | { |
||
34 | |||
35 | /// <summary> Factory method for creating instances of this class.</summary> |
||
36 | /// <param name="src">-- source of image data |
||
37 | /// </param> |
||
38 | /// <param name="csMap">-- provides colorspace info |
||
39 | /// </param> |
||
40 | /// <returns> SYccColorSpaceMapper instance |
||
41 | /// </returns> |
||
42 | public static new BlkImgDataSrc createInstance(BlkImgDataSrc src, ColorSpace csMap) |
||
43 | { |
||
44 | return new EsRgbColorSpaceMapper(src, csMap); |
||
45 | } |
||
46 | |||
47 | /// <summary> Ctor which creates an ICCProfile for the image and initializes |
||
48 | /// all data objects (input, working, and output). |
||
49 | /// |
||
50 | /// </summary> |
||
51 | /// <param name="src">-- Source of image data |
||
52 | /// </param> |
||
53 | /// <param name="csm">-- provides colorspace info |
||
54 | /// </param> |
||
55 | protected internal EsRgbColorSpaceMapper(BlkImgDataSrc src, ColorSpace csMap):base(src, csMap) |
||
56 | { |
||
57 | initialize(); |
||
58 | } |
||
59 | |||
60 | /// <summary>General utility used by ctors </summary> |
||
61 | private void initialize() |
||
62 | { |
||
63 | |||
64 | if (ncomps != 1 && ncomps != 3) |
||
65 | { |
||
66 | System.String msg = "EsRgbColorSpaceMapper: e-sRGB transformation _not_ applied to " + ncomps + " component image"; |
||
67 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.ERROR, msg); |
||
68 | throw new ColorSpaceException(msg); |
||
69 | } |
||
70 | } |
||
71 | |||
72 | |||
73 | /// <summary> |
||
74 | /// <para>Returns, in the blk argument, a block of image data containing the |
||
75 | /// specifed rectangular area, in the specified component. The data is |
||
76 | /// returned, as a copy of the internal data, therefore the returned data |
||
77 | /// can be modified "in place".</para> |
||
78 | /// |
||
79 | /// <para>The rectangular area to return is specified by the 'ulx', 'uly', 'w' |
||
80 | /// and 'h' members of the 'blk' argument, relative to the current |
||
81 | /// tile. These members are not modified by this method. The 'offset' of |
||
82 | /// the returned data is 0, and the 'scanw' is the same as the block's |
||
83 | /// width. See the 'DataBlk' class.</para> |
||
84 | /// |
||
85 | /// <para>If the data array in 'blk' is 'null', then a new one is created. If |
||
86 | /// the data array is not 'null' then it is reused, and it must be large |
||
87 | /// enough to contain the block's data. Otherwise an 'ArrayStoreException' |
||
88 | /// or an 'IndexOutOfBoundsException' is thrown by the Java system.</para> |
||
89 | /// |
||
90 | /// <para>The returned data has its 'progressive' attribute set to that of the |
||
91 | /// input data.</para> |
||
92 | /// |
||
93 | /// </summary> |
||
94 | /// <param name="blk">Its coordinates and dimensions specify the area to |
||
95 | /// return. If it contains a non-null data array, then it must have the |
||
96 | /// correct dimensions. If it contains a null data array a new one is |
||
97 | /// created. The fields in this object are modified to return the data. |
||
98 | /// |
||
99 | /// </param> |
||
100 | /// <param name="c">The index of the component from which to get the data. Only 0 |
||
101 | /// and 3 are valid. |
||
102 | /// |
||
103 | /// </param> |
||
104 | /// <returns> The requested DataBlk |
||
105 | /// </returns> |
||
106 | /// <seealso cref="getInternCompData"> |
||
107 | /// |
||
108 | /// </seealso> |
||
109 | public override DataBlk getCompData(DataBlk outblk, int c) |
||
110 | { |
||
111 | |||
112 | int type = outblk.DataType; |
||
113 | double colors = Math.Pow(2, src.getNomRangeBits(c)); |
||
114 | double bitoff=colors*0.375D; |
||
115 | if (type == DataBlk.TYPE_INT) |
||
116 | { |
||
117 | DataBlkInt intblk=(DataBlkInt)src.getInternCompData(outblk, c); |
||
118 | |||
119 | for (int i = 0; i < intblk.data_array.Length; i++) |
||
120 | { |
||
121 | int tmp = intblk.data_array[i]; |
||
122 | |||
123 | tmp += (int)(colors / 2); |
||
124 | tmp -= (int)bitoff; |
||
125 | tmp *= 2; |
||
126 | tmp -= (int)(colors / 2); |
||
127 | |||
128 | intblk.data_array[i] = tmp; |
||
129 | } |
||
130 | outblk = intblk; |
||
131 | } |
||
132 | else if (type == DataBlk.TYPE_FLOAT) |
||
133 | { |
||
134 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported e-sRGB DataType (float)"); |
||
135 | |||
136 | DataBlkFloat fltblk = (DataBlkFloat)src.getInternCompData(outblk, c); |
||
137 | outblk = fltblk; |
||
138 | } |
||
139 | return outblk; |
||
140 | } |
||
141 | |||
142 | /// <summary> Returns, in the blk argument, a block of image data containing the |
||
143 | /// specifed rectangular area, in the specified component. The data is |
||
144 | /// returned, as a reference to the internal data, if any, instead of as a |
||
145 | /// copy, therefore the returned data should not be modified. |
||
146 | /// |
||
147 | /// <P>The rectangular area to return is specified by the 'ulx', 'uly', 'w' |
||
148 | /// and 'h' members of the 'blk' argument, relative to the current |
||
149 | /// tile. These members are not modified by this method. The 'offset' and |
||
150 | /// 'scanw' of the returned data can be arbitrary. See the 'DataBlk' class. |
||
151 | /// |
||
152 | /// <P>This method, in general, is more efficient than the 'getCompData()' |
||
153 | /// method since it may not copy the data. However if the array of returned |
||
154 | /// data is to be modified by the caller then the other method is probably |
||
155 | /// preferable. |
||
156 | /// |
||
157 | /// <P>If possible, the data in the returned 'DataBlk' should be the |
||
158 | /// internal data itself, instead of a copy, in order to increase the data |
||
159 | /// transfer efficiency. However, this depends on the particular |
||
160 | /// implementation (it may be more convenient to just return a copy of the |
||
161 | /// data). This is the reason why the returned data should not be modified. |
||
162 | /// |
||
163 | /// <P>If the data array in <tt>blk</tt> is <tt>null</tt>, then a new one |
||
164 | /// is created if necessary. The implementation of this interface may |
||
165 | /// choose to return the same array or a new one, depending on what is more |
||
166 | /// efficient. Therefore, the data array in <tt>blk</tt> prior to the |
||
167 | /// method call should not be considered to contain the returned data, a |
||
168 | /// new array may have been created. Instead, get the array from |
||
169 | /// <tt>blk</tt> after the method has returned. |
||
170 | /// |
||
171 | /// <P>The returned data may have its 'progressive' attribute set. In this |
||
172 | /// case the returned data is only an approximation of the "final" data. |
||
173 | /// |
||
174 | /// </summary> |
||
175 | /// <param name="blk">Its coordinates and dimensions specify the area to return, |
||
176 | /// relative to the current tile. Some fields in this object are modified |
||
177 | /// to return the data. |
||
178 | /// |
||
179 | /// </param> |
||
180 | /// <param name="c">The index of the component from which to get the data. |
||
181 | /// |
||
182 | /// </param> |
||
183 | /// <returns> The requested DataBlk |
||
184 | /// |
||
185 | /// </returns> |
||
186 | /// <seealso cref="getCompData"> |
||
187 | /// </seealso> |
||
188 | public override DataBlk getInternCompData(DataBlk out_Renamed, int c) |
||
189 | { |
||
190 | return getCompData(out_Renamed, c); |
||
191 | } |
||
192 | |||
193 | /// <summary>Return a suitable String representation of the class instance. </summary> |
||
194 | public override System.String ToString() |
||
195 | { |
||
196 | int i; |
||
197 | |||
198 | System.Text.StringBuilder rep_nComps = new System.Text.StringBuilder("ncomps= ").Append(System.Convert.ToString(ncomps)); |
||
199 | System.Text.StringBuilder rep_comps = new System.Text.StringBuilder(); |
||
200 | |||
201 | for (i = 0; i < ncomps; ++i) |
||
202 | { |
||
203 | rep_comps.Append(" ").Append("component[").Append(System.Convert.ToString(i)).Append("] height, width = (").Append(src.getCompImgHeight(i)).Append(", ").Append(src.getCompImgWidth(i)).Append(")").Append(eol); |
||
204 | } |
||
205 | |||
206 | System.Text.StringBuilder rep = new System.Text.StringBuilder("[EsRGBColorSpaceMapper "); |
||
207 | rep.Append(rep_nComps).Append(eol); |
||
208 | rep.Append(rep_comps).Append(" "); |
||
209 | |||
210 | return rep.Append("]").ToString(); |
||
211 | } |
||
212 | } |
||
213 | } |