use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class MyAttrNode method test3.
public static void test3() {
IIOMetadataNode parent = new IIOMetadataNode("parent");
MyAttrNode attrNode = new MyAttrNode("name", "value");
Attr retAttr = parent.setAttributeNode(attrNode);
if (retAttr != null) {
throw new RuntimeException("Test 3 failed: Return value is " + "non-null");
}
}
use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class MyAttrNode method test4.
public static void test4() {
String name = "name";
String correctValue = "correct value";
String wrongValue = "wrong value";
IIOMetadataNode parent = new IIOMetadataNode("parent");
MyAttrNode attrNode1 = new MyAttrNode(name, wrongValue);
MyAttrNode attrNode2 = new MyAttrNode(name, correctValue);
parent.setAttributeNode(attrNode1);
parent.setAttributeNode(attrNode2);
Attr actAttr = parent.getAttributeNode(name);
String actValue = actAttr.getValue();
if (!actValue.equals(correctValue)) {
throw new RuntimeException("Test 4 failed: Return value is: " + actValue);
}
}
use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class ShortHistogramTest method gethISTNode.
private IIOMetadataNode gethISTNode(BufferedImage bi) {
IndexColorModel icm = (IndexColorModel) bi.getColorModel();
int mapSize = icm.getMapSize();
int[] hist = new int[mapSize];
Arrays.fill(hist, 0);
Raster r = bi.getData();
for (int y = 0; y < bi.getHeight(); y++) {
for (int x = 0; x < bi.getWidth(); x++) {
int s = r.getSample(x, y, 0);
hist[s]++;
}
}
IIOMetadataNode hIST = new IIOMetadataNode("hIST");
for (int i = 0; i < hist.length; i++) {
IIOMetadataNode n = new IIOMetadataNode("hISTEntry");
n.setAttribute("index", "" + i);
n.setAttribute("value", "" + hist[i]);
hIST.appendChild(n);
}
return hIST;
}
use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class BMPMetadata method getStandardDataNode.
protected IIOMetadataNode getStandardDataNode() {
IIOMetadataNode node = new IIOMetadataNode("Data");
String bits = "";
if (bitsPerPixel == 24)
bits = "8 8 8 ";
else if (bitsPerPixel == 16 || bitsPerPixel == 32) {
bits = "" + countBits(redMask) + " " + countBits(greenMask) + countBits(blueMask) + "" + countBits(alphaMask);
}
IIOMetadataNode subNode = new IIOMetadataNode("BitsPerSample");
subNode.setAttribute("value", bits);
node.appendChild(subNode);
return node;
}
use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class BMPMetadata method getNativeTree.
private Node getNativeTree() {
IIOMetadataNode root = new IIOMetadataNode(nativeMetadataFormatName);
addChildNode(root, "BMPVersion", bmpVersion);
addChildNode(root, "Width", new Integer(width));
addChildNode(root, "Height", new Integer(height));
addChildNode(root, "BitsPerPixel", new Short(bitsPerPixel));
addChildNode(root, "Compression", new Integer(compression));
addChildNode(root, "ImageSize", new Integer(imageSize));
IIOMetadataNode node = addChildNode(root, "PixelsPerMeter", null);
addChildNode(node, "X", new Integer(xPixelsPerMeter));
addChildNode(node, "Y", new Integer(yPixelsPerMeter));
addChildNode(root, "ColorsUsed", new Integer(colorsUsed));
addChildNode(root, "ColorsImportant", new Integer(colorsImportant));
int version = 0;
for (int i = 0; i < bmpVersion.length(); i++) if (Character.isDigit(bmpVersion.charAt(i)))
version = bmpVersion.charAt(i) - '0';
if (version >= 4) {
node = addChildNode(root, "Mask", null);
addChildNode(node, "Red", new Integer(redMask));
addChildNode(node, "Green", new Integer(greenMask));
addChildNode(node, "Blue", new Integer(blueMask));
addChildNode(node, "Alpha", new Integer(alphaMask));
addChildNode(root, "ColorSpaceType", new Integer(colorSpace));
node = addChildNode(root, "CIEXYZEndPoints", null);
addXYZPoints(node, "Red", redX, redY, redZ);
addXYZPoints(node, "Green", greenX, greenY, greenZ);
addXYZPoints(node, "Blue", blueX, blueY, blueZ);
node = addChildNode(root, "Intent", new Integer(intent));
}
// Palette
if ((palette != null) && (paletteSize > 0)) {
node = addChildNode(root, "Palette", null);
int numComps = palette.length / paletteSize;
for (int i = 0, j = 0; i < paletteSize; i++) {
IIOMetadataNode entry = addChildNode(node, "PaletteEntry", null);
red = palette[j++] & 0xff;
green = palette[j++] & 0xff;
blue = palette[j++] & 0xff;
addChildNode(entry, "Red", new Byte((byte) red));
addChildNode(entry, "Green", new Byte((byte) green));
addChildNode(entry, "Blue", new Byte((byte) blue));
if (numComps == 4)
addChildNode(entry, "Alpha", new Byte((byte) (palette[j++] & 0xff)));
}
}
return root;
}
Aggregations