Search in sources :

Example 31 with IIOMetadataNode

use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.

the class PNGMetadata method getStandardDataNode.

public IIOMetadataNode getStandardDataNode() {
    IIOMetadataNode data_node = new IIOMetadataNode("Data");
    // scratch node
    IIOMetadataNode node = null;
    node = new IIOMetadataNode("PlanarConfiguration");
    node.setAttribute("value", "PixelInterleaved");
    data_node.appendChild(node);
    node = new IIOMetadataNode("SampleFormat");
    node.setAttribute("value", IHDR_colorType == PNGImageReader.PNG_COLOR_PALETTE ? "Index" : "UnsignedIntegral");
    data_node.appendChild(node);
    String bitDepth = Integer.toString(IHDR_bitDepth);
    node = new IIOMetadataNode("BitsPerSample");
    node.setAttribute("value", repeat(bitDepth, getNumChannels()));
    data_node.appendChild(node);
    if (sBIT_present) {
        node = new IIOMetadataNode("SignificantBitsPerSample");
        String sbits;
        if (sBIT_colorType == PNGImageReader.PNG_COLOR_GRAY || sBIT_colorType == PNGImageReader.PNG_COLOR_GRAY_ALPHA) {
            sbits = Integer.toString(sBIT_grayBits);
        } else {
            // sBIT_colorType == PNGImageReader.PNG_COLOR_RGB ||
            // sBIT_colorType == PNGImageReader.PNG_COLOR_RGB_ALPHA
            sbits = Integer.toString(sBIT_redBits) + " " + Integer.toString(sBIT_greenBits) + " " + Integer.toString(sBIT_blueBits);
        }
        if (sBIT_colorType == PNGImageReader.PNG_COLOR_GRAY_ALPHA || sBIT_colorType == PNGImageReader.PNG_COLOR_RGB_ALPHA) {
            sbits += " " + Integer.toString(sBIT_alphaBits);
        }
        node.setAttribute("value", sbits);
        data_node.appendChild(node);
    }
    return data_node;
}
Also used : IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode)

Example 32 with IIOMetadataNode

use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.

the class SOFMarkerSegment method getNativeNode.

IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("sof");
    node.setAttribute("process", Integer.toString(tag - JPEG.SOF0));
    node.setAttribute("samplePrecision", Integer.toString(samplePrecision));
    node.setAttribute("numLines", Integer.toString(numLines));
    node.setAttribute("samplesPerLine", Integer.toString(samplesPerLine));
    node.setAttribute("numFrameComponents", Integer.toString(componentSpecs.length));
    for (int i = 0; i < componentSpecs.length; i++) {
        node.appendChild(componentSpecs[i].getNativeNode());
    }
    return node;
}
Also used : IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode)

Example 33 with IIOMetadataNode

use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.

the class JPEGMetadata method getNativeTree.

IIOMetadataNode getNativeTree() {
    IIOMetadataNode root;
    IIOMetadataNode top;
    Iterator iter = markerSequence.iterator();
    if (isStream) {
        root = new IIOMetadataNode(JPEG.nativeStreamMetadataFormatName);
        top = root;
    } else {
        IIOMetadataNode sequence = new IIOMetadataNode("markerSequence");
        if (!inThumb) {
            root = new IIOMetadataNode(JPEG.nativeImageMetadataFormatName);
            IIOMetadataNode header = new IIOMetadataNode("JPEGvariety");
            root.appendChild(header);
            JFIFMarkerSegment jfif = (JFIFMarkerSegment) findMarkerSegment(JFIFMarkerSegment.class, true);
            if (jfif != null) {
                // JFIF must be first, so this skips it
                iter.next();
                header.appendChild(jfif.getNativeNode());
            }
            root.appendChild(sequence);
        } else {
            root = sequence;
        }
        top = sequence;
    }
    while (iter.hasNext()) {
        MarkerSegment seg = (MarkerSegment) iter.next();
        top.appendChild(seg.getNativeNode());
    }
    return root;
}
Also used : ListIterator(java.util.ListIterator) Iterator(java.util.Iterator) IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode)

Example 34 with IIOMetadataNode

use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.

the class JPEGMetadata method getStandardChromaNode.

// Standard tree node methods
protected IIOMetadataNode getStandardChromaNode() {
    // Unless we find otherwise
    hasAlpha = false;
    // Colorspace type - follow the rules in the spec
    // First get the SOF marker segment, if there is one
    SOFMarkerSegment sof = (SOFMarkerSegment) findMarkerSegment(SOFMarkerSegment.class, true);
    if (sof == null) {
        // No image, so no chroma
        return null;
    }
    IIOMetadataNode chroma = new IIOMetadataNode("Chroma");
    IIOMetadataNode csType = new IIOMetadataNode("ColorSpaceType");
    chroma.appendChild(csType);
    // get the number of channels
    int numChannels = sof.componentSpecs.length;
    IIOMetadataNode numChanNode = new IIOMetadataNode("NumChannels");
    chroma.appendChild(numChanNode);
    numChanNode.setAttribute("value", Integer.toString(numChannels));
    // is there a JFIF marker segment?
    if (findMarkerSegment(JFIFMarkerSegment.class, true) != null) {
        if (numChannels == 1) {
            csType.setAttribute("name", "GRAY");
        } else {
            csType.setAttribute("name", "YCbCr");
        }
        return chroma;
    }
    // How about an Adobe marker segment?
    AdobeMarkerSegment adobe = (AdobeMarkerSegment) findMarkerSegment(AdobeMarkerSegment.class, true);
    if (adobe != null) {
        switch(adobe.transform) {
            case JPEG.ADOBE_YCCK:
                csType.setAttribute("name", "YCCK");
                break;
            case JPEG.ADOBE_YCC:
                csType.setAttribute("name", "YCbCr");
                break;
            case JPEG.ADOBE_UNKNOWN:
                if (numChannels == 3) {
                    csType.setAttribute("name", "RGB");
                } else if (numChannels == 4) {
                    csType.setAttribute("name", "CMYK");
                }
                break;
        }
        return chroma;
    }
    // Neither marker.  Check components
    if (numChannels < 3) {
        csType.setAttribute("name", "GRAY");
        if (numChannels == 2) {
            hasAlpha = true;
        }
        return chroma;
    }
    boolean idsAreJFIF = true;
    for (int i = 0; i < sof.componentSpecs.length; i++) {
        int id = sof.componentSpecs[i].componentId;
        if ((id < 1) || (id >= sof.componentSpecs.length)) {
            idsAreJFIF = false;
        }
    }
    if (idsAreJFIF) {
        csType.setAttribute("name", "YCbCr");
        if (numChannels == 4) {
            hasAlpha = true;
        }
        return chroma;
    }
    // Check against the letters
    if ((sof.componentSpecs[0].componentId == 'R') && (sof.componentSpecs[1].componentId == 'G') && (sof.componentSpecs[2].componentId == 'B')) {
        csType.setAttribute("name", "RGB");
        if ((numChannels == 4) && (sof.componentSpecs[3].componentId == 'A')) {
            hasAlpha = true;
        }
        return chroma;
    }
    if ((sof.componentSpecs[0].componentId == 'Y') && (sof.componentSpecs[1].componentId == 'C') && (sof.componentSpecs[2].componentId == 'c')) {
        csType.setAttribute("name", "PhotoYCC");
        if ((numChannels == 4) && (sof.componentSpecs[3].componentId == 'A')) {
            hasAlpha = true;
        }
        return chroma;
    }
    // Finally, 3-channel subsampled are YCbCr, unsubsampled are RGB
    // 4-channel subsampled are YCbCrA, unsubsampled are CMYK
    boolean subsampled = false;
    int hfactor = sof.componentSpecs[0].HsamplingFactor;
    int vfactor = sof.componentSpecs[0].VsamplingFactor;
    for (int i = 1; i < sof.componentSpecs.length; i++) {
        if ((sof.componentSpecs[i].HsamplingFactor != hfactor) || (sof.componentSpecs[i].VsamplingFactor != vfactor)) {
            subsampled = true;
            break;
        }
    }
    if (subsampled) {
        csType.setAttribute("name", "YCbCr");
        if (numChannels == 4) {
            hasAlpha = true;
        }
        return chroma;
    }
    // Not subsampled.  numChannels < 3 is taken care of above
    if (numChannels == 3) {
        csType.setAttribute("name", "RGB");
    } else {
        csType.setAttribute("name", "CMYK");
    }
    return chroma;
}
Also used : IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode) Point(java.awt.Point)

Example 35 with IIOMetadataNode

use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.

the class DQTMarkerSegment method getNativeNode.

IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("dqt");
    for (int i = 0; i < tables.size(); i++) {
        Qtable table = (Qtable) tables.get(i);
        node.appendChild(table.getNativeNode());
    }
    return node;
}
Also used : IIOMetadataNode(javax.imageio.metadata.IIOMetadataNode)

Aggregations

IIOMetadataNode (javax.imageio.metadata.IIOMetadataNode)65 Iterator (java.util.Iterator)5 IIOImage (javax.imageio.IIOImage)4 IIOMetadata (javax.imageio.metadata.IIOMetadata)4 Node (org.w3c.dom.Node)4 BufferedImage (java.awt.image.BufferedImage)3 ListIterator (java.util.ListIterator)3 ImageTypeSpecifier (javax.imageio.ImageTypeSpecifier)3 ImageWriter (javax.imageio.ImageWriter)3 ImageOutputStream (javax.imageio.stream.ImageOutputStream)3 Attr (org.w3c.dom.Attr)3 Graphics (java.awt.Graphics)2 Point (java.awt.Point)2 IndexColorModel (java.awt.image.IndexColorModel)2 ImageReader (javax.imageio.ImageReader)2 Element (org.w3c.dom.Element)2 ProductFlavorContainer (com.android.builder.model.ProductFlavorContainer)1 AndroidModel (com.android.tools.idea.model.AndroidModel)1 ChatPanel (com.glitchcog.fontificator.gui.chat.ChatPanel)1 Module (com.intellij.openapi.module.Module)1