corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | /// <summary>************************************************************************** |
2 | /// |
||
3 | /// $Id: ColorSpecificationBox.java,v 1.3 2002/08/08 14:07: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.util; |
||
11 | using CSJ2K.j2k.io; |
||
12 | using CSJ2K.Color; |
||
13 | using CSJ2K.Icc; |
||
14 | namespace CSJ2K.Color.Boxes |
||
15 | { |
||
16 | |||
17 | /// <summary> This class models the Color Specification Box in a JP2 image. |
||
18 | /// |
||
19 | /// </summary> |
||
20 | /// <version> 1.0 |
||
21 | /// </version> |
||
22 | /// <author> Bruce A. Kern |
||
23 | /// </author> |
||
24 | public sealed class ColorSpecificationBox:JP2Box |
||
25 | { |
||
26 | |||
27 | public ColorSpace.MethodEnum Method |
||
28 | { |
||
29 | // Return an enumeration for the colorspace method. |
||
30 | |||
31 | get |
||
32 | { |
||
33 | return method; |
||
34 | } |
||
35 | |||
36 | } |
||
37 | public ColorSpace.CSEnum ColorSpace |
||
38 | { |
||
39 | // Return an enumeration for the colorspace. |
||
40 | |||
41 | get |
||
42 | { |
||
43 | return colorSpace; |
||
44 | } |
||
45 | |||
46 | } |
||
47 | |||
48 | public System.String ColorSpaceString |
||
49 | { |
||
50 | // Return a String representation of the colorspace. |
||
51 | |||
52 | get |
||
53 | { |
||
54 | return colorSpace.ToString(); |
||
55 | } |
||
56 | |||
57 | } |
||
58 | public System.String MethodString |
||
59 | { |
||
60 | // Return a String representation of the colorspace method. |
||
61 | |||
62 | get |
||
63 | { |
||
64 | return method.ToString(); |
||
65 | } |
||
66 | |||
67 | } |
||
68 | |||
69 | public byte[] ICCProfile |
||
70 | { |
||
71 | /* Retrieve the ICC Profile from the image as a byte []. */ |
||
72 | |||
73 | get |
||
74 | { |
||
75 | return iccProfile; |
||
76 | } |
||
77 | |||
78 | } |
||
79 | |||
80 | private ColorSpace.MethodEnum method; |
||
81 | private ColorSpace.CSEnum colorSpace; |
||
82 | private byte[] iccProfile = null; |
||
83 | |||
84 | /// <summary> Construct a ColorSpecificationBox from an input image.</summary> |
||
85 | /// <param name="in">RandomAccessIO jp2 image |
||
86 | /// </param> |
||
87 | /// <param name="boxStart">offset to the start of the box in the image |
||
88 | /// </param> |
||
89 | /// <exception cref="IOException,">ColorSpaceException |
||
90 | /// |
||
91 | /// </exception> |
||
92 | public ColorSpecificationBox(RandomAccessIO in_Renamed, int boxStart):base(in_Renamed, boxStart) |
||
93 | { |
||
94 | readBox(); |
||
95 | } |
||
96 | |||
97 | /// <summary>Analyze the box content. </summary> |
||
98 | private void readBox() |
||
99 | { |
||
100 | byte[] boxHeader = new byte[256]; |
||
101 | in_Renamed.seek(dataStart); |
||
102 | in_Renamed.readFully(boxHeader, 0, 11); |
||
103 | switch (boxHeader[0]) |
||
104 | { |
||
105 | |||
106 | case 1: |
||
107 | method = CSJ2K.Color.ColorSpace.MethodEnum.ENUMERATED; |
||
108 | int cs = CSJ2K.Icc.ICCProfile.getInt(boxHeader, 3); |
||
109 | switch (cs) |
||
110 | { |
||
111 | case 16: |
||
112 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.sRGB; |
||
113 | break; // from switch (cs)... |
||
114 | |||
115 | case 17: |
||
116 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.GreyScale; |
||
117 | break; // from switch (cs)... |
||
118 | |||
119 | case 18: |
||
120 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.sYCC; |
||
121 | break; // from switch (cs)... |
||
122 | case 20: |
||
123 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.esRGB; |
||
124 | break; |
||
125 | |||
126 | #region Known but unsupported colorspaces |
||
127 | case 3: |
||
128 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YCbCr(2) in color specification box"); |
||
129 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
130 | break; |
||
131 | case 4: |
||
132 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YCbCr(3) in color specification box"); |
||
133 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
134 | break; |
||
135 | case 9: |
||
136 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace PhotoYCC in color specification box"); |
||
137 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
138 | break; |
||
139 | case 11: |
||
140 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace CMY in color specification box"); |
||
141 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
142 | break; |
||
143 | case 12: |
||
144 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace CMYK in color specification box"); |
||
145 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
146 | break; |
||
147 | case 13: |
||
148 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YCCK in color specification box"); |
||
149 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
150 | break; |
||
151 | case 14: |
||
152 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace CIELab in color specification box"); |
||
153 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
154 | break; |
||
155 | case 15: |
||
156 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace Bi-Level(2) in color specification box"); |
||
157 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
158 | break; |
||
159 | case 19: |
||
160 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace CIEJab in color specification box"); |
||
161 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
162 | break; |
||
163 | case 21: |
||
164 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace ROMM-RGB in color specification box"); |
||
165 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
166 | break; |
||
167 | case 22: |
||
168 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YPbPr(1125/60) in color specification box"); |
||
169 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
170 | break; |
||
171 | case 23: |
||
172 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace YPbPr(1250/50) in color specification box"); |
||
173 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
174 | break; |
||
175 | case 24: |
||
176 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unsupported enumerated colorspace e-sYCC in color specification box"); |
||
177 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
178 | break; |
||
179 | #endregion |
||
180 | |||
181 | default: |
||
182 | FacilityManager.getMsgLogger().printmsg(CSJ2K.j2k.util.MsgLogger_Fields.WARNING, "Unknown enumerated colorspace (" + cs + ") in color specification box"); |
||
183 | colorSpace = CSJ2K.Color.ColorSpace.CSEnum.Unknown; |
||
184 | break; |
||
185 | |||
186 | } |
||
187 | break; // from switch (boxHeader[0])... |
||
188 | |||
189 | case 2: |
||
190 | method = CSJ2K.Color.ColorSpace.MethodEnum.ICC_PROFILED; |
||
191 | int size = CSJ2K.Icc.ICCProfile.getInt(boxHeader, 3); |
||
192 | iccProfile = new byte[size]; |
||
193 | in_Renamed.seek(dataStart + 3); |
||
194 | in_Renamed.readFully(iccProfile, 0, size); |
||
195 | break; // from switch (boxHeader[0])... |
||
196 | |||
197 | default: |
||
198 | throw new ColorSpaceException("Bad specification method (" + boxHeader[0] + ") in " + this); |
||
199 | |||
200 | } |
||
201 | } |
||
202 | |||
203 | /// <summary>Return a suitable String representation of the class instance. </summary> |
||
204 | public override System.String ToString() |
||
205 | { |
||
206 | System.Text.StringBuilder rep = new System.Text.StringBuilder("[ColorSpecificationBox "); |
||
207 | rep.Append("method= ").Append(System.Convert.ToString(method)).Append(", "); |
||
208 | rep.Append("colorspace= ").Append(System.Convert.ToString(colorSpace)).Append("]"); |
||
209 | return rep.ToString(); |
||
210 | } |
||
211 | |||
212 | /* end class ColorSpecificationBox */ |
||
213 | static ColorSpecificationBox() |
||
214 | { |
||
215 | { |
||
216 | type = 0x636f6c72; |
||
217 | } |
||
218 | } |
||
219 | } |
||
220 | } |