M
mah5
Hi,
I am new to the imageio package and would really appreciate some help
with writing animated GIF images. I'm trying to set the delay between
frames. I can write animated GIFs without problem but am having setting
GIF meta data.
Here's a snippet of code:
ImageWriter gifWriter = getWriter(offScreenImage);
ImageWriteParam imageWriteParam = gifWriter.getDefaultWriteParam();
IIOMetadata metaData =
gifWriter.getDefaultStreamMetadata(imageWriteParam);
String metaFormatName = metaData.getNativeMetadataFormatName();
IIOMetadataNode root = (IIOMetadataNode)
metaData.getAsTree(metaFormatName);
IIOMetadataNode child = new
IIOMetadataNode("GraphicControlExtension");
child.setAttribute("disposalMethod", "none");
child.setAttribute("userInputFlag", "FALSE");
child.setAttribute("transparentColorFlag", "FALSE");
child.setAttribute("delayTime", Integer.toString(timeBetweenFramesMS /
10));
child.setAttribute("transparentColorIndex", "0");
root.appendChild(child);
metaData.setFromTree(metaFormatName, root);
When I run this, an exception is thrown:
javax.imageio.metadata.IIOInvalidTreeException: Unknown child of root
node!
at
com.sun.imageio.plugins.gif.GIFMetadata.fatal(GIFMetadata.java:34)
at
com.sun.imageio.plugins.gif.GIFWritableStreamMetadata.mergeNativeTree(GIFWritableStreamMetadata.java:142)
at
com.sun.imageio.plugins.gif.GIFWritableStreamMetadata.mergeTree(GIFWritableStreamMetadata.java:50)
at
com.sun.imageio.plugins.gif.GIFWritableStreamMetadata.setFromTree(GIFWritableStreamMetadata.java:247)
at
com.xinapse.apps.jim.AnimatedGIFWriterThread.run(AnimatedGIFWriterThread.java:152)
I'm a bit stumped. It seems pretty straight-forward that I add a new
child to the root node to specify the GraphicControlExtension. Any help
would be appreciated as I'm tearing my hair out.
Thanks
Mark
I am new to the imageio package and would really appreciate some help
with writing animated GIF images. I'm trying to set the delay between
frames. I can write animated GIFs without problem but am having setting
GIF meta data.
Here's a snippet of code:
ImageWriter gifWriter = getWriter(offScreenImage);
ImageWriteParam imageWriteParam = gifWriter.getDefaultWriteParam();
IIOMetadata metaData =
gifWriter.getDefaultStreamMetadata(imageWriteParam);
String metaFormatName = metaData.getNativeMetadataFormatName();
IIOMetadataNode root = (IIOMetadataNode)
metaData.getAsTree(metaFormatName);
IIOMetadataNode child = new
IIOMetadataNode("GraphicControlExtension");
child.setAttribute("disposalMethod", "none");
child.setAttribute("userInputFlag", "FALSE");
child.setAttribute("transparentColorFlag", "FALSE");
child.setAttribute("delayTime", Integer.toString(timeBetweenFramesMS /
10));
child.setAttribute("transparentColorIndex", "0");
root.appendChild(child);
metaData.setFromTree(metaFormatName, root);
When I run this, an exception is thrown:
javax.imageio.metadata.IIOInvalidTreeException: Unknown child of root
node!
at
com.sun.imageio.plugins.gif.GIFMetadata.fatal(GIFMetadata.java:34)
at
com.sun.imageio.plugins.gif.GIFWritableStreamMetadata.mergeNativeTree(GIFWritableStreamMetadata.java:142)
at
com.sun.imageio.plugins.gif.GIFWritableStreamMetadata.mergeTree(GIFWritableStreamMetadata.java:50)
at
com.sun.imageio.plugins.gif.GIFWritableStreamMetadata.setFromTree(GIFWritableStreamMetadata.java:247)
at
com.xinapse.apps.jim.AnimatedGIFWriterThread.run(AnimatedGIFWriterThread.java:152)
I'm a bit stumped. It seems pretty straight-forward that I add a new
child to the root node to specify the GraphicControlExtension. Any help
would be appreciated as I'm tearing my hair out.
Thanks
Mark