1 7 8 package com.sun.imageio.plugins.bmp; 9 10 import java.util.Arrays ; 11 import javax.imageio.ImageTypeSpecifier ; 12 import javax.imageio.metadata.IIOMetadataFormat ; 13 import javax.imageio.metadata.IIOMetadataFormatImpl ; 14 15 public class BMPMetadataFormat extends IIOMetadataFormatImpl { 16 17 private static IIOMetadataFormat instance = null; 18 19 private BMPMetadataFormat() { 20 super(BMPMetadata.nativeMetadataFormatName, 21 CHILD_POLICY_SOME); 22 23 addElement("ImageDescriptor", 25 BMPMetadata.nativeMetadataFormatName, 26 CHILD_POLICY_EMPTY); 27 addAttribute("ImageDescriptor", "bmpVersion", 28 DATATYPE_STRING, true, null); 29 addAttribute("ImageDescriptor", "width", 30 DATATYPE_INTEGER, true, null, 31 "0", "65535", true, true); 32 addAttribute("ImageDescriptor", "height", 33 DATATYPE_INTEGER, true, null, 34 "1", "65535", true, true); 35 addAttribute("ImageDescriptor", "bitsPerPixel", 36 DATATYPE_INTEGER, true, null, 37 "1", "65535", true, true); 38 addAttribute("ImageDescriptor", "compression", 39 DATATYPE_INTEGER, false, null); 40 addAttribute("ImageDescriptor", "imageSize", 41 DATATYPE_INTEGER, true, null, 42 "1", "65535", true, true); 43 44 addElement("PixelsPerMeter", 45 BMPMetadata.nativeMetadataFormatName, 46 CHILD_POLICY_EMPTY); 47 addAttribute("PixelsPerMeter", "X", 48 DATATYPE_INTEGER, false, null, 49 "1", "65535", true, true); 50 addAttribute("PixelsPerMeter", "Y", 51 DATATYPE_INTEGER, false, null, 52 "1", "65535", true, true); 53 54 addElement("ColorsUsed", 55 BMPMetadata.nativeMetadataFormatName, 56 CHILD_POLICY_EMPTY); 57 addAttribute("ColorsUsed", "value", 58 DATATYPE_INTEGER, true, null, 59 "0", "65535", true, true); 60 61 addElement("ColorsImportant", 62 BMPMetadata.nativeMetadataFormatName, 63 CHILD_POLICY_EMPTY); 64 addAttribute("ColorsImportant", "value", 65 DATATYPE_INTEGER, false, null, 66 "0", "65535", true, true); 67 68 addElement("BI_BITFIELDS_Mask", 69 BMPMetadata.nativeMetadataFormatName, 70 CHILD_POLICY_EMPTY); 71 addAttribute("BI_BITFIELDS_Mask", "red", 72 DATATYPE_INTEGER, false, null, 73 "0", "65535", true, true); 74 addAttribute("BI_BITFIELDS_Mask", "green", 75 DATATYPE_INTEGER, false, null, 76 "0", "65535", true, true); 77 addAttribute("BI_BITFIELDS_Mask", "blue", 78 DATATYPE_INTEGER, false, null, 79 "0", "65535", true, true); 80 81 addElement("ColorSpace", 82 BMPMetadata.nativeMetadataFormatName, 83 CHILD_POLICY_EMPTY); 84 addAttribute("ColorSpace", "value", 85 DATATYPE_INTEGER, false, null, 86 "0", "65535", true, true); 87 88 addElement("LCS_CALIBRATED_RGB", 89 BMPMetadata.nativeMetadataFormatName, 90 CHILD_POLICY_EMPTY); 91 92 addAttribute("LCS_CALIBRATED_RGB", "redX", 94 DATATYPE_DOUBLE, false, null, 95 "0", "65535", true, true); 96 addAttribute("LCS_CALIBRATED_RGB", "redY", 97 DATATYPE_DOUBLE, false, null, 98 "0", "65535", true, true); 99 addAttribute("LCS_CALIBRATED_RGB", "redZ", 100 DATATYPE_DOUBLE, false, null, 101 "0", "65535", true, true); 102 addAttribute("LCS_CALIBRATED_RGB", "greenX", 103 DATATYPE_DOUBLE, false, null, 104 "0", "65535", true, true); 105 addAttribute("LCS_CALIBRATED_RGB", "greenY", 106 DATATYPE_DOUBLE, false, null, 107 "0", "65535", true, true); 108 addAttribute("LCS_CALIBRATED_RGB", "greenZ", 109 DATATYPE_DOUBLE, false, null, 110 "0", "65535", true, true); 111 addAttribute("LCS_CALIBRATED_RGB", "blueX", 112 DATATYPE_DOUBLE, false, null, 113 "0", "65535", true, true); 114 addAttribute("LCS_CALIBRATED_RGB", "blueY", 115 DATATYPE_DOUBLE, false, null, 116 "0", "65535", true, true); 117 addAttribute("LCS_CALIBRATED_RGB", "blueZ", 118 DATATYPE_DOUBLE, false, null, 119 "0", "65535", true, true); 120 121 addElement("LCS_CALIBRATED_RGB_GAMMA", 122 BMPMetadata.nativeMetadataFormatName, 123 CHILD_POLICY_EMPTY); 124 addAttribute("LCS_CALIBRATED_RGB_GAMMA","red", 125 DATATYPE_INTEGER, false, null, 126 "0", "65535", true, true); 127 addAttribute("LCS_CALIBRATED_RGB_GAMMA","green", 128 DATATYPE_INTEGER, false, null, 129 "0", "65535", true, true); 130 addAttribute("LCS_CALIBRATED_RGB_GAMMA","blue", 131 DATATYPE_INTEGER, false, null, 132 "0", "65535", true, true); 133 134 addElement("Intent", 135 BMPMetadata.nativeMetadataFormatName, 136 CHILD_POLICY_EMPTY); 137 addAttribute("Intent", "value", 138 DATATYPE_INTEGER, false, null, 139 "0", "65535", true, true); 140 141 addElement("Palette", 143 BMPMetadata.nativeMetadataFormatName, 144 2, 256); 145 addAttribute("Palette", "sizeOfPalette", 146 DATATYPE_INTEGER, true, null); 147 addBooleanAttribute("Palette", "sortFlag", 148 false, false); 149 150 addElement("PaletteEntry", "Palette", 152 CHILD_POLICY_EMPTY); 153 addAttribute("PaletteEntry", "index", 154 DATATYPE_INTEGER, true, null, 155 "0", "255", true, true); 156 addAttribute("PaletteEntry", "red", 157 DATATYPE_INTEGER, true, null, 158 "0", "255", true, true); 159 addAttribute("PaletteEntry", "green", 160 DATATYPE_INTEGER, true, null, 161 "0", "255", true, true); 162 addAttribute("PaletteEntry", "blue", 163 DATATYPE_INTEGER, true, null, 164 "0", "255", true, true); 165 166 167 addElement("CommentExtensions", 169 BMPMetadata.nativeMetadataFormatName, 170 1, Integer.MAX_VALUE); 171 172 addElement("CommentExtension", "CommentExtensions", 174 CHILD_POLICY_EMPTY); 175 addAttribute("CommentExtension", "value", 176 DATATYPE_STRING, true, null); 177 } 178 179 public boolean canNodeAppear(String elementName, 180 ImageTypeSpecifier imageType) { 181 return true; 182 } 183 184 public static synchronized IIOMetadataFormat getInstance() { 185 if (instance == null) { 186 instance = new BMPMetadataFormat(); 187 } 188 return instance; 189 } 190 } 191 | Popular Tags |