Package javax.imageio.metadata

Examples of javax.imageio.metadata.IIOMetadataNode


        }
    }

    private static Node createDri(Node n, int interval){

        IIOMetadataNode dri = new IIOMetadataNode("dri");
        dri.setAttribute("interval",Integer.toString(interval));
        NodeList nl= n.getChildNodes();
        nl.item(1).insertBefore(dri, nl.item(1).getFirstChild());
        return n;
    }
View Full Code Here


     * @param loops - 0 = loop continuously; 1-65535 = a specific number of loops
     * @throws IIOInvalidTreeException
     */
    private static void setLoops(IIOMetadata metaData, int loops) throws IIOInvalidTreeException {
        Node tree = metaData.getAsTree(formatName);
        IIOMetadataNode aes = new IIOMetadataNode(aesNodeName);
        IIOMetadataNode ae = new IIOMetadataNode(aeNodeName);
        ae.setAttribute("applicationID", "NETSCAPE");
        ae.setAttribute("authenticationCode", "2.0");
        ae.setUserObject(new byte[]{0x1, (byte) (loops & 0xFF), (byte) ((loops >> 8) & 0xFF)});
        aes.appendChild(ae);
        tree.appendChild(aes);
        metaData.setFromTree(formatName, tree);
    }
View Full Code Here

    private ICC_Profile tryToExctractICCProfileFromPNGMetadataNode(
            Element pngNode) {
        ICC_Profile iccProf = null;
        Element iccpNode = ImageIOUtil.getChild(pngNode, "iCCP");
        if (iccpNode instanceof IIOMetadataNode) {
            IIOMetadataNode imn = (IIOMetadataNode) iccpNode;
            byte[] prof = (byte[]) imn.getUserObject();
            String comp = imn.getAttribute("compressionMethod");
            if ("deflate".equalsIgnoreCase(comp)) {
                Inflater decompresser = new Inflater();
                decompresser.setInput(prof);
                byte[] result = new byte[100];
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
View Full Code Here

        ICC_Profile iccProf = null;
        Element jfifNode = ImageIOUtil.getChild(jpgNode, "app0JFIF");
        if (jfifNode != null) {
            Element app2iccNode = ImageIOUtil.getChild(jfifNode, "app2ICC");
            if (app2iccNode instanceof IIOMetadataNode) {
                IIOMetadataNode imn = (IIOMetadataNode) app2iccNode;
                iccProf = (ICC_Profile) imn.getUserObject();
            }
        }
        return iccProf;
    }
View Full Code Here

        //that happens.
        if (params.getResolution() != null) {
            if (SUN_TIFF_NATIVE_FORMAT.equals(meta.getNativeMetadataFormatName())) {

                //IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(SUN_TIFF_NATIVE_FORMAT);
                IIOMetadataNode root = new IIOMetadataNode(SUN_TIFF_NATIVE_FORMAT);

                IIOMetadataNode ifd = getChildNode(root, "TIFFIFD");
                if (ifd == null) {
                    ifd = new IIOMetadataNode("TIFFIFD");
                    ifd.setAttribute("tagSets",
                                "com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet");
                    root.appendChild(ifd);
                }
                ifd.appendChild(createResolutionField(282, "XResolution", params));
                ifd.appendChild(createResolutionField(283, "YResolution", params));

                //ResolutionUnit
                IIOMetadataNode field, arrayNode, valueNode;
                field = new IIOMetadataNode("TIFFField");
                field.setAttribute("number", Integer.toString(296));
                field.setAttribute("name", "ResolutionUnit");
                arrayNode = new IIOMetadataNode("TIFFShorts");
                field.appendChild(arrayNode);
                valueNode = new IIOMetadataNode("TIFFShort");
                valueNode.setAttribute("value", Integer.toString(3));
                valueNode.setAttribute("description", "Centimeter");
                arrayNode.appendChild(valueNode);

                try {
View Full Code Here

        return ret;
    }

    private IIOMetadataNode createResolutionField(int number, String name, ImageWriterParams params) {
        IIOMetadataNode field, arrayNode, valueNode;
        field = new IIOMetadataNode("TIFFField");
        field.setAttribute("number", Integer.toString(number));
        field.setAttribute("name", name);
        arrayNode = new IIOMetadataNode("TIFFRationals");
        field.appendChild(arrayNode);
        valueNode = new IIOMetadataNode("TIFFRational");
        arrayNode.appendChild(valueNode);

        // Set target resolution
        float pixSzMM = 25.4f / params.getResolution().floatValue();
        // num Pixs in 100 Meters
View Full Code Here

        {
            LOG.debug("Using unknown TIFF image writer: " + metadata.getNativeMetadataFormatName());
            return;
        }

        IIOMetadataNode root = new IIOMetadataNode(SUN_TIFF_FORMAT);
        IIOMetadataNode ifd;
        if (root.getElementsByTagName("TIFFIFD").getLength() == 0)
        {
            ifd = new IIOMetadataNode("TIFFIFD");
            ifd.setAttribute("tagSets",
                             "com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet");
            root.appendChild(ifd);
        }
        else
        {
            ifd = (IIOMetadataNode)root.getElementsByTagName("TIFFIFD").item(0);
        }

        // standard metadata does not work, so we set the DPI manually
        ifd.appendChild(createRationalField(282, "XResolution", dpi, 1));
        ifd.appendChild(createRationalField(283, "YResolution", dpi, 1));
        ifd.appendChild(createShortField(296, "ResolutionUnit", 2)); // Inch

        ifd.appendChild(createLongField(278, "RowsPerStrip", image.getHeight()));
        ifd.appendChild(createAsciiField(305, "Software", "PDFBOX"));

        if (image.getType() == BufferedImage.TYPE_BYTE_BINARY &&
                image.getColorModel().getPixelSize() == 1)
        {
            // set PhotometricInterpretation WhiteIsZero
            // because of bug in Windows XP preview
            ifd.appendChild(createShortField(262, "PhotometricInterpretation", 0));
        }
       
        try
        {
            metadata.mergeTree(SUN_TIFF_FORMAT, root);
View Full Code Here

        debugLogMetadata(metadata, SUN_TIFF_FORMAT);
    }

    private static IIOMetadataNode createShortField(int tiffTagNumber, String name, int val)
    {
        IIOMetadataNode field, arrayNode, valueNode;
        field = new IIOMetadataNode("TIFFField");
        field.setAttribute("number", Integer.toString(tiffTagNumber));
        field.setAttribute("name", name);
        arrayNode = new IIOMetadataNode("TIFFShorts");
        field.appendChild(arrayNode);
        valueNode = new IIOMetadataNode("TIFFShort");
        arrayNode.appendChild(valueNode);
        valueNode.setAttribute("value", Integer.toString(val));
        return field;
    }
View Full Code Here

        return field;
    }

    private static IIOMetadataNode createAsciiField(int number, String name, String val)
    {
        IIOMetadataNode field, arrayNode, valueNode;
        field = new IIOMetadataNode("TIFFField");
        field.setAttribute("number", Integer.toString(number));
        field.setAttribute("name", name);
        arrayNode = new IIOMetadataNode("TIFFAsciis");
        field.appendChild(arrayNode);
        valueNode = new IIOMetadataNode("TIFFAscii");
        arrayNode.appendChild(valueNode);
        valueNode.setAttribute("value", val);
        return field;
    }
View Full Code Here

        return field;
    }

    private static IIOMetadataNode createLongField(int number, String name, long val)
    {
        IIOMetadataNode field, arrayNode, valueNode;
        field = new IIOMetadataNode("TIFFField");
        field.setAttribute("number", Integer.toString(number));
        field.setAttribute("name", name);
        arrayNode = new IIOMetadataNode("TIFFLongs");
        field.appendChild(arrayNode);
        valueNode = new IIOMetadataNode("TIFFLong");
        arrayNode.appendChild(valueNode);
        valueNode.setAttribute("value", Long.toString(val));
        return field;
    }
View Full Code Here

TOP

Related Classes of javax.imageio.metadata.IIOMetadataNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.