Search in sources :

Example 81 with IIOMetadataNode

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");
    }
}
Also used : IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode) Attr(org.w3c.dom.Attr)

Example 82 with IIOMetadataNode

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);
    }
}
Also used : IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode) Attr(org.w3c.dom.Attr)

Example 83 with IIOMetadataNode

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;
}
Also used : Raster(java.awt.image.Raster) IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode) IndexColorModel(java.awt.image.IndexColorModel)

Example 84 with IIOMetadataNode

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;
}
Also used : IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode)

Example 85 with IIOMetadataNode

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;
}
Also used : IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode)

Aggregations

IIOMetadataNode (javax.imageio.metadata.IIOMetadataNode)132 Node (org.w3c.dom.Node)20 IIOMetadata (javax.imageio.metadata.IIOMetadata)12 NodeList (org.w3c.dom.NodeList)12 TIFFField (it.geosolutions.imageio.plugins.tiff.TIFFField)10 Iterator (java.util.Iterator)9 BufferedImage (java.awt.image.BufferedImage)8 ArrayList (java.util.ArrayList)8 ASOCBoxMetadataNode (it.geosolutions.imageio.plugins.jp2k.box.ASOCBoxMetadataNode)5 UUIDBoxMetadataNode (it.geosolutions.imageio.plugins.jp2k.box.UUIDBoxMetadataNode)5 XMLBoxMetadataNode (it.geosolutions.imageio.plugins.jp2k.box.XMLBoxMetadataNode)5 IOException (java.io.IOException)5 ImageOutputStream (javax.imageio.stream.ImageOutputStream)5 File (java.io.File)4 IIOImage (javax.imageio.IIOImage)4 ImageTypeSpecifier (javax.imageio.ImageTypeSpecifier)4 ImageWriter (javax.imageio.ImageWriter)4 TIFFTag (it.geosolutions.imageio.plugins.tiff.TIFFTag)3 Color (java.awt.Color)3 Point (java.awt.Point)3