History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/imageio/plugins/bmp/BMPMetadataFormat.java (1 of 18352 files). Show all

Unified · Split

java/pkg/com/sun/imageio/plugins/bmp/BMPMetadataFormat.java+208−0
@@ -0,0 +1,208 @@
1/*
2 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.imageio.plugins.bmp;
27
28import java.util.Arrays;
29import javax.imageio.ImageTypeSpecifier;
30import javax.imageio.metadata.IIOMetadataFormat;
31import javax.imageio.metadata.IIOMetadataFormatImpl;
32
33public class BMPMetadataFormat extends IIOMetadataFormatImpl {
34
35 private static IIOMetadataFormat instance = null;
36
37 private BMPMetadataFormat() {
38 super(BMPMetadata.nativeMetadataFormatName,
39 CHILD_POLICY_SOME);
40
41 // root -> ImageDescriptor
42 addElement("ImageDescriptor",
43 BMPMetadata.nativeMetadataFormatName,
44 CHILD_POLICY_EMPTY);
45 addAttribute("ImageDescriptor", "bmpVersion",
46 DATATYPE_STRING, true, null);
47 addAttribute("ImageDescriptor", "width",
48 DATATYPE_INTEGER, true, null,
49 "0", "65535", true, true);
50 addAttribute("ImageDescriptor", "height",
51 DATATYPE_INTEGER, true, null,
52 "1", "65535", true, true);
53 addAttribute("ImageDescriptor", "bitsPerPixel",
54 DATATYPE_INTEGER, true, null,
55 "1", "65535", true, true);
56 addAttribute("ImageDescriptor", "compression",
57 DATATYPE_INTEGER, false, null);
58 addAttribute("ImageDescriptor", "imageSize",
59 DATATYPE_INTEGER, true, null,
60 "1", "65535", true, true);
61
62 addElement("PixelsPerMeter",
63 BMPMetadata.nativeMetadataFormatName,
64 CHILD_POLICY_EMPTY);
65 addAttribute("PixelsPerMeter", "X",
66 DATATYPE_INTEGER, false, null,
67 "1", "65535", true, true);
68 addAttribute("PixelsPerMeter", "Y",
69 DATATYPE_INTEGER, false, null,
70 "1", "65535", true, true);
71
72 addElement("ColorsUsed",
73 BMPMetadata.nativeMetadataFormatName,
74 CHILD_POLICY_EMPTY);
75 addAttribute("ColorsUsed", "value",
76 DATATYPE_INTEGER, true, null,
77 "0", "65535", true, true);
78
79 addElement("ColorsImportant",
80 BMPMetadata.nativeMetadataFormatName,
81 CHILD_POLICY_EMPTY);
82 addAttribute("ColorsImportant", "value",
83 DATATYPE_INTEGER, false, null,
84 "0", "65535", true, true);
85
86 addElement("BI_BITFIELDS_Mask",
87 BMPMetadata.nativeMetadataFormatName,
88 CHILD_POLICY_EMPTY);
89 addAttribute("BI_BITFIELDS_Mask", "red",
90 DATATYPE_INTEGER, false, null,
91 "0", "65535", true, true);
92 addAttribute("BI_BITFIELDS_Mask", "green",
93 DATATYPE_INTEGER, false, null,
94 "0", "65535", true, true);
95 addAttribute("BI_BITFIELDS_Mask", "blue",
96 DATATYPE_INTEGER, false, null,
97 "0", "65535", true, true);
98
99 addElement("ColorSpace",
100 BMPMetadata.nativeMetadataFormatName,
101 CHILD_POLICY_EMPTY);
102 addAttribute("ColorSpace", "value",
103 DATATYPE_INTEGER, false, null,
104 "0", "65535", true, true);
105
106 addElement("LCS_CALIBRATED_RGB",
107 BMPMetadata.nativeMetadataFormatName,
108 CHILD_POLICY_EMPTY);
109
110 /// Should the max value be 1.7976931348623157e+308 ?
111 addAttribute("LCS_CALIBRATED_RGB", "redX",
112 DATATYPE_DOUBLE, false, null,
113 "0", "65535", true, true);
114 addAttribute("LCS_CALIBRATED_RGB", "redY",
115 DATATYPE_DOUBLE, false, null,
116 "0", "65535", true, true);
117 addAttribute("LCS_CALIBRATED_RGB", "redZ",
118 DATATYPE_DOUBLE, false, null,
119 "0", "65535", true, true);
120 addAttribute("LCS_CALIBRATED_RGB", "greenX",
121 DATATYPE_DOUBLE, false, null,
122 "0", "65535", true, true);
123 addAttribute("LCS_CALIBRATED_RGB", "greenY",
124 DATATYPE_DOUBLE, false, null,
125 "0", "65535", true, true);
126 addAttribute("LCS_CALIBRATED_RGB", "greenZ",
127 DATATYPE_DOUBLE, false, null,
128 "0", "65535", true, true);
129 addAttribute("LCS_CALIBRATED_RGB", "blueX",
130 DATATYPE_DOUBLE, false, null,
131 "0", "65535", true, true);
132 addAttribute("LCS_CALIBRATED_RGB", "blueY",
133 DATATYPE_DOUBLE, false, null,
134 "0", "65535", true, true);
135 addAttribute("LCS_CALIBRATED_RGB", "blueZ",
136 DATATYPE_DOUBLE, false, null,
137 "0", "65535", true, true);
138
139 addElement("LCS_CALIBRATED_RGB_GAMMA",
140 BMPMetadata.nativeMetadataFormatName,
141 CHILD_POLICY_EMPTY);
142 addAttribute("LCS_CALIBRATED_RGB_GAMMA","red",
143 DATATYPE_INTEGER, false, null,
144 "0", "65535", true, true);
145 addAttribute("LCS_CALIBRATED_RGB_GAMMA","green",
146 DATATYPE_INTEGER, false, null,
147 "0", "65535", true, true);
148 addAttribute("LCS_CALIBRATED_RGB_GAMMA","blue",
149 DATATYPE_INTEGER, false, null,
150 "0", "65535", true, true);
151
152 addElement("Intent",
153 BMPMetadata.nativeMetadataFormatName,
154 CHILD_POLICY_EMPTY);
155 addAttribute("Intent", "value",
156 DATATYPE_INTEGER, false, null,
157 "0", "65535", true, true);
158
159 // root -> Palette
160 addElement("Palette",
161 BMPMetadata.nativeMetadataFormatName,
162 2, 256);
163 addAttribute("Palette", "sizeOfPalette",
164 DATATYPE_INTEGER, true, null);
165 addBooleanAttribute("Palette", "sortFlag",
166 false, false);
167
168 // root -> Palette -> PaletteEntry
169 addElement("PaletteEntry", "Palette",
170 CHILD_POLICY_EMPTY);
171 addAttribute("PaletteEntry", "index",
172 DATATYPE_INTEGER, true, null,
173 "0", "255", true, true);
174 addAttribute("PaletteEntry", "red",
175 DATATYPE_INTEGER, true, null,
176 "0", "255", true, true);
177 addAttribute("PaletteEntry", "green",
178 DATATYPE_INTEGER, true, null,
179 "0", "255", true, true);
180 addAttribute("PaletteEntry", "blue",
181 DATATYPE_INTEGER, true, null,
182 "0", "255", true, true);
183
184
185 // root -> CommentExtensions
186 addElement("CommentExtensions",
187 BMPMetadata.nativeMetadataFormatName,
188 1, Integer.MAX_VALUE);
189
190 // root -> CommentExtensions -> CommentExtension
191 addElement("CommentExtension", "CommentExtensions",
192 CHILD_POLICY_EMPTY);
193 addAttribute("CommentExtension", "value",
194 DATATYPE_STRING, true, null);
195 }
196
197 public boolean canNodeAppear(String elementName,
198 ImageTypeSpecifier imageType) {
199 return true;
200 }
201
202 public static synchronized IIOMetadataFormat getInstance() {
203 if (instance == null) {
204 instance = new BMPMetadataFormat();
205 }
206 return instance;
207 }
208}