[英]What is the constructor in this Java file doing?
I just stumbled upon this GifSequenceWriter here http://dke-tron.googlecode.com/svn-history/r39/trunk/src/nl/unimaas/games/tron/util/GifSequenceWriter.java . 我在这里http://dke-tron.googlecode.com/svn-history/r39/trunk/src/nl/unimaas/games/tron/util/GifSequenceWriter.java偶然发现了这个GifSequenceWriter。 The code of the constructor is this:
构造函数的代码是这样的:
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);
}
Is simply dont understand what this constructor is essentially doing? 就是根本不了解此构造函数在做什么? Just writing some Metadata?
只是写一些元数据? can someone explain me this?
有人可以向我解释吗? Why do I need metadata?
为什么需要元数据?
The constructor is apparently setting up the GifSequenceWriter
so that the initial metadata with the proper content will have been written to the underlying output stream. 构造函数显然正在设置
GifSequenceWriter
以便将具有适当内容的初始元数据写入到基础输出流中。
Analogous behavior can be seen in ObjectOutputStream
, where the constructor writes header information to the underlying stream. 在
ObjectOutputStream
可以看到类似的行为,其中构造函数将标头信息写入底层流。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.