Java Code Examples for javax.imageio.metadata.IIOMetadataNode#setUserObject()

The following examples show how to use javax.imageio.metadata.IIOMetadataNode#setUserObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WBMPMetadata.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private IIOMetadataNode addChildNode(IIOMetadataNode root,
                                     String name,
                                     Object object) {
    IIOMetadataNode child = new IIOMetadataNode(name);
    if (object != null) {
        child.setUserObject(object);
        child.setNodeValue(ImageUtil.convertObjectToString(object));
    }
    root.appendChild(child);
    return child;
}
 
Example 2
Source File: MarkerSegment.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("unknown");
    node.setAttribute("MarkerTag", Integer.toString(tag));
    node.setUserObject(data);

    return node;
}
 
Example 3
Source File: DQTMarkerSegment.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("dqtable");
    node.setAttribute("elementPrecision",
                      Integer.toString(elementPrecision));
    node.setAttribute("qtableId",
                      Integer.toString(tableID));
    node.setUserObject(new JPEGQTable(data));
    return node;
}
 
Example 4
Source File: COMMarkerSegment.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an <code>IIOMetadataNode</code> containing the data array
 * as a user object and a string encoded using ISO-8895-1, as an
 * attribute.
 */
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("com");
    node.setAttribute("comment", getComment());
    if (data != null) {
        node.setUserObject(data.clone());
    }
    return node;
}
 
Example 5
Source File: BMPMetadata.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private IIOMetadataNode addChildNode(IIOMetadataNode root,
                                     String name,
                                     Object object) {
    IIOMetadataNode child = new IIOMetadataNode(name);
    if (object != null) {
        child.setUserObject(object);
        child.setNodeValue(ImageUtil.convertObjectToString(object));
    }
    root.appendChild(child);
    return child;
}
 
Example 6
Source File: MarkerSegment.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("unknown");
    node.setAttribute("MarkerTag", Integer.toString(tag));
    node.setUserObject(data);

    return node;
}
 
Example 7
Source File: MarkerSegment.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("unknown");
    node.setAttribute("MarkerTag", Integer.toString(tag));
    node.setUserObject(data);

    return node;
}
 
Example 8
Source File: DQTMarkerSegment.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("dqtable");
    node.setAttribute("elementPrecision",
                      Integer.toString(elementPrecision));
    node.setAttribute("qtableId",
                      Integer.toString(tableID));
    node.setUserObject(new JPEGQTable(data));
    return node;
}
 
Example 9
Source File: DHTMarkerSegment.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("dhtable");
    node.setAttribute("class", Integer.toString(tableClass));
    node.setAttribute("htableId", Integer.toString(tableID));

    node.setUserObject(new JPEGHuffmanTable(numCodes, values));

    return node;
}
 
Example 10
Source File: MarkerSegment.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("unknown");
    node.setAttribute("MarkerTag", Integer.toString(tag));
    node.setUserObject(data);

    return node;
}
 
Example 11
Source File: WBMPMetadata.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private IIOMetadataNode addChildNode(IIOMetadataNode root,
                                     String name,
                                     Object object) {
    IIOMetadataNode child = new IIOMetadataNode(name);
    if (object != null) {
        child.setUserObject(object);
        child.setNodeValue(ImageUtil.convertObjectToString(object));
    }
    root.appendChild(child);
    return child;
}
 
Example 12
Source File: COMMarkerSegment.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an {@code IIOMetadataNode} containing the data array
 * as a user object and a string encoded using ISO-8895-1, as an
 * attribute.
 */
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("com");
    node.setAttribute("comment", getComment());
    if (data != null) {
        node.setUserObject(data.clone());
    }
    return node;
}
 
Example 13
Source File: DQTMarkerSegment.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("dqtable");
    node.setAttribute("elementPrecision",
                      Integer.toString(elementPrecision));
    node.setAttribute("qtableId",
                      Integer.toString(tableID));
    node.setUserObject(new JPEGQTable(data));
    return node;
}
 
Example 14
Source File: COMMarkerSegment.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns an <code>IIOMetadataNode</code> containing the data array
 * as a user object and a string encoded using ISO-8895-1, as an
 * attribute.
 */
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("com");
    node.setAttribute("comment", getComment());
    if (data != null) {
        node.setUserObject(data.clone());
    }
    return node;
}
 
Example 15
Source File: WBMPMetadata.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private IIOMetadataNode addChildNode(IIOMetadataNode root,
                                     String name,
                                     Object object) {
    IIOMetadataNode child = new IIOMetadataNode(name);
    if (object != null) {
        child.setUserObject(object);
        child.setNodeValue(ImageUtil.convertObjectToString(object));
    }
    root.appendChild(child);
    return child;
}
 
Example 16
Source File: BMPMetadata.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private IIOMetadataNode addChildNode(IIOMetadataNode root,
                                     String name,
                                     Object object) {
    IIOMetadataNode child = new IIOMetadataNode(name);
    if (object != null) {
        child.setUserObject(object);
        child.setNodeValue(ImageUtil.convertObjectToString(object));
    }
    root.appendChild(child);
    return child;
}
 
Example 17
Source File: JFIFMarkerSegment.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("app2ICC");
    if (profile != null) {
        node.setUserObject(ICC_Profile.getInstance(profile));
    }
    return node;
}
 
Example 18
Source File: DQTMarkerSegment.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
IIOMetadataNode getNativeNode() {
    IIOMetadataNode node = new IIOMetadataNode("dqtable");
    node.setAttribute("elementPrecision",
                      Integer.toString(elementPrecision));
    node.setAttribute("qtableId",
                      Integer.toString(tableID));
    node.setUserObject(new JPEGQTable(data));
    return node;
}
 
Example 19
Source File: GifSequenceWriter.java    From AsciidocFX with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new GifSequenceWriter
 *
 * @param outputStream        the ImageOutputStream to be written to
 * @param imageType           one of the imageTypes specified in BufferedImage
 * @param timeBetweenFramesMS the time between frames in miliseconds
 * @param loopContinuously    wether the gif should loop repeatedly
 * @throws IIOException if no gif ImageWriters are found
 * @author Elliot Kroo (elliot[at]kroo[dot]net)
 */
public GifSequenceWriter(
        ImageOutputStream outputStream,
        int imageType,
        int timeBetweenFramesMS,
        boolean loopContinuously) throws IIOException, IOException {
    // my method to create a writer
    gifWriter = getWriter();
    imageWriteParam = gifWriter.getDefaultWriteParam();
    ImageTypeSpecifier imageTypeSpecifier =
            ImageTypeSpecifier.createFromBufferedImageType(imageType);

    imageMetaData =
            gifWriter.getDefaultImageMetadata(imageTypeSpecifier,
                    imageWriteParam);

    String metaFormatName = imageMetaData.getNativeMetadataFormatName();

    IIOMetadataNode root = (IIOMetadataNode)
            imageMetaData.getAsTree(metaFormatName);

    IIOMetadataNode graphicsControlExtensionNode = getNode(
            root,
            "GraphicControlExtension");

    graphicsControlExtensionNode.setAttribute("disposalMethod", "none");
    graphicsControlExtensionNode.setAttribute("userInputFlag", "FALSE");
    graphicsControlExtensionNode.setAttribute(
            "transparentColorFlag",
            "FALSE");
    graphicsControlExtensionNode.setAttribute(
            "delayTime",
            Integer.toString(timeBetweenFramesMS / 10));
    graphicsControlExtensionNode.setAttribute(
            "transparentColorIndex",
            "0");

    IIOMetadataNode commentsNode = getNode(root, "CommentExtensions");
    commentsNode.setAttribute("CommentExtension", "Created by MAH");

    IIOMetadataNode appEntensionsNode = getNode(
            root,
            "ApplicationExtensions");

    IIOMetadataNode child = new IIOMetadataNode("ApplicationExtension");

    child.setAttribute("applicationID", "NETSCAPE");
    child.setAttribute("authenticationCode", "2.0");

    int loop = loopContinuously ? 0 : 1;

    child.setUserObject(new byte[]{0x1, (byte) (loop & 0xFF), (byte)
            ((loop >> 8) & 0xFF)});
    appEntensionsNode.appendChild(child);

    imageMetaData.setFromTree(metaFormatName, root);

    gifWriter.setOutput(outputStream);

    gifWriter.prepareWriteSequence(null);
}
 
Example 20
Source File: GifSequenceWriter.java    From graphicsfuzz with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new GifSequenceWriter.
 *
 * @param outputStream the ImageOutputStream to be written to
 * @param imageType one of the imageTypes specified in BufferedImage
 * @param timeBetweenFramesMs the time between frames in miliseconds
 * @param loopContinuously wether the gif should loop repeatedly
 * @throws IIOException if no gif ImageWriters are found
 *
 * @author Elliot Kroo (elliot[at]kroo[dot]net)
 */
public GifSequenceWriter(
    ImageOutputStream outputStream,
    int imageType,
    int timeBetweenFramesMs,
    boolean loopContinuously) throws IIOException, IOException {
  // my method to create a writer
  gifWriter = getWriter();
  imageWriteParam = gifWriter.getDefaultWriteParam();
  ImageTypeSpecifier imageTypeSpecifier =
      ImageTypeSpecifier.createFromBufferedImageType(imageType);

  imageMetaData =
      gifWriter.getDefaultImageMetadata(imageTypeSpecifier,
          imageWriteParam);

  String metaFormatName = imageMetaData.getNativeMetadataFormatName();

  IIOMetadataNode root = (IIOMetadataNode)
      imageMetaData.getAsTree(metaFormatName);

  IIOMetadataNode graphicsControlExtensionNode = getNode(
      root,
      "GraphicControlExtension");

  graphicsControlExtensionNode.setAttribute("disposalMethod", "none");
  graphicsControlExtensionNode.setAttribute("userInputFlag", "FALSE");
  graphicsControlExtensionNode.setAttribute(
      "transparentColorFlag",
      "FALSE");
  graphicsControlExtensionNode.setAttribute(
      "delayTime",
      Integer.toString(timeBetweenFramesMs / 10));
  graphicsControlExtensionNode.setAttribute(
      "transparentColorIndex",
      "0");

  IIOMetadataNode commentsNode = getNode(root, "CommentExtensions");
  commentsNode.setAttribute("CommentExtension", "Created by MAH");

  IIOMetadataNode child = new IIOMetadataNode("ApplicationExtension");

  child.setAttribute("applicationID", "NETSCAPE");
  child.setAttribute("authenticationCode", "2.0");

  IIOMetadataNode appEntensionsNode = getNode(
      root,
      "ApplicationExtensions");

  int loop = loopContinuously ? 0 : 1;

  child.setUserObject(new byte[]{ 0x1, (byte) (loop & 0xFF), (byte)
      ((loop >> 8) & 0xFF)});
  appEntensionsNode.appendChild(child);

  imageMetaData.setFromTree(metaFormatName, root);

  gifWriter.setOutput(outputStream);

  gifWriter.prepareWriteSequence(null);
}