FileDocCategorySizeDatePackage
GIFStreamMetadata.javaAPI DocJava SE 5 API9488Fri Aug 26 14:54:42 BST 2005com.sun.imageio.plugins.gif

GIFStreamMetadata

public class GIFStreamMetadata extends IIOMetadata
version
0.5

Fields Summary
static final String
nativeMetadataFormatName
public static final String[]
versionStrings
public String
version
public int
logicalScreenWidth
public int
logicalScreenHeight
public int
colorResolution
public int
pixelAspectRatio
public int
backgroundColorIndex
public boolean
sortFlag
public static final String[]
colorTableSizes
public byte[]
globalColorTable
Constructors Summary
public GIFStreamMetadata()


      
        super(true, 
              nativeMetadataFormatName,
              "com.sun.imageio.plugins.gif.GIFStreamMetadataFormat",
              null, null);

    
Methods Summary
public org.w3c.dom.NodegetAsTree(java.lang.String formatName)

        if (formatName.equals(nativeMetadataFormatName)) {
            return getNativeTree();
        } else if (formatName.equals
                   (IIOMetadataFormatImpl.standardMetadataFormatName)) {
            return getStandardTree();
        } else {
            throw new IllegalArgumentException("Not a recognized format!");
        }
    
private org.w3c.dom.NodegetNativeTree()

        IIOMetadataNode node; // scratch node
        IIOMetadataNode root =
            new IIOMetadataNode(nativeMetadataFormatName);
            
        node = new IIOMetadataNode("Version");
        node.setAttribute("value", version);
        root.appendChild(node);
        
        // Image descriptor
        node = new IIOMetadataNode("LogicalScreenDescriptor");
        node.setAttribute("logicalScreenWidth",
                          Integer.toString(logicalScreenWidth));
        node.setAttribute("logicalScreenHeight",
                          Integer.toString(logicalScreenHeight));
        // Stored value plus one
        node.setAttribute("colorResolution",
                          Integer.toString(colorResolution));
        node.setAttribute("pixelAspectRatio",
                          Integer.toString(pixelAspectRatio));
        root.appendChild(node);

        if (globalColorTable != null) {
            node = new IIOMetadataNode("GlobalColorTable");
            int numEntries = globalColorTable.length/3;
            node.setAttribute("sizeOfGlobalColorTable",
                              Integer.toString(numEntries));
            node.setAttribute("backgroundColorIndex",
                              Integer.toString(backgroundColorIndex));
            node.setAttribute("sortFlag",
                              sortFlag ? "TRUE" : "FALSE");

            for (int i = 0; i < numEntries; i++) {
                IIOMetadataNode entry =
                    new IIOMetadataNode("ColorTableEntry");
                entry.setAttribute("index", Integer.toString(i));
                int r = globalColorTable[3*i] & 0xff;
                int g = globalColorTable[3*i + 1] & 0xff;
                int b = globalColorTable[3*i + 2] & 0xff;
                entry.setAttribute("red", Integer.toString(r));
                entry.setAttribute("green", Integer.toString(g));
                entry.setAttribute("blue", Integer.toString(b));
                node.appendChild(entry);
            }
            root.appendChild(node);
        }

        return root;
    
public javax.imageio.metadata.IIOMetadataNodegetStandardChromaNode()

        IIOMetadataNode chroma_node = new IIOMetadataNode("Chroma");
        IIOMetadataNode node = null; // scratch node

        node = new IIOMetadataNode("ColorSpaceType");
        node.setAttribute("name", "RGB");
        chroma_node.appendChild(node);

        node = new IIOMetadataNode("BlackIsZero");
        node.setAttribute("value", "TRUE");
        chroma_node.appendChild(node);

        // NumChannels not in stream
        // Gamma not in format

        if (globalColorTable != null) {
            node = new IIOMetadataNode("Palette");
            int numEntries = globalColorTable.length/3;
            for (int i = 0; i < numEntries; i++) {
                IIOMetadataNode entry =
                    new IIOMetadataNode("PaletteEntry");
                entry.setAttribute("index", Integer.toString(i));
                entry.setAttribute("red",
                           Integer.toString(globalColorTable[3*i] & 0xff));
                entry.setAttribute("green",
                           Integer.toString(globalColorTable[3*i + 1] & 0xff));
                entry.setAttribute("blue",
                           Integer.toString(globalColorTable[3*i + 2] & 0xff));
                node.appendChild(entry);
            }
            chroma_node.appendChild(node);

            // backgroundColorIndex is valid iff there is a color table
            node = new IIOMetadataNode("BackgroundIndex");
            node.setAttribute("value", Integer.toString(backgroundColorIndex));
            chroma_node.appendChild(node);
        }

        return chroma_node;
    
public javax.imageio.metadata.IIOMetadataNodegetStandardCompressionNode()

        IIOMetadataNode compression_node = new IIOMetadataNode("Compression");
        IIOMetadataNode node = null; // scratch node

        node = new IIOMetadataNode("CompressionTypeName");
        node.setAttribute("value", "lzw");
        compression_node.appendChild(node);

        node = new IIOMetadataNode("Lossless");
        node.setAttribute("value", "true");
        compression_node.appendChild(node);

        // NumProgressiveScans not in stream
        // BitRate not in format

        return compression_node;
    
public javax.imageio.metadata.IIOMetadataNodegetStandardDataNode()

        IIOMetadataNode data_node = new IIOMetadataNode("Data");
        IIOMetadataNode node = null; // scratch node

        // PlanarConfiguration

        node = new IIOMetadataNode("SampleFormat");
        node.setAttribute("value", "Index");
        data_node.appendChild(node);

        node = new IIOMetadataNode("BitsPerSample");
        node.setAttribute("value", Integer.toString(colorResolution));
        data_node.appendChild(node);
        
        // SignificantBitsPerSample
        // SampleMSB
        
        return data_node;
    
public javax.imageio.metadata.IIOMetadataNodegetStandardDimensionNode()

        IIOMetadataNode dimension_node = new IIOMetadataNode("Dimension");
        IIOMetadataNode node = null; // scratch node

        node = new IIOMetadataNode("PixelAspectRatio");
        float aspectRatio = 1.0F;
        if (pixelAspectRatio != 0) {
            aspectRatio = (pixelAspectRatio + 15)/64.0F;
        }
        node.setAttribute("value", Float.toString(aspectRatio));
        dimension_node.appendChild(node);

        node = new IIOMetadataNode("ImageOrientation");
        node.setAttribute("value", "Normal");
        dimension_node.appendChild(node);

        // HorizontalPixelSize not in format
        // VerticalPixelSize not in format
        // HorizontalPhysicalPixelSpacing not in format
        // VerticalPhysicalPixelSpacing not in format
        // HorizontalPosition not in format
        // VerticalPosition not in format
        // HorizontalPixelOffset not in stream
        // VerticalPixelOffset not in stream

        node = new IIOMetadataNode("HorizontalScreenSize");
        node.setAttribute("value", Integer.toString(logicalScreenWidth));
        dimension_node.appendChild(node);
        
        node = new IIOMetadataNode("VerticalScreenSize");
        node.setAttribute("value", Integer.toString(logicalScreenHeight));
        dimension_node.appendChild(node);
        
        return dimension_node;
    
public javax.imageio.metadata.IIOMetadataNodegetStandardDocumentNode()

        IIOMetadataNode document_node = new IIOMetadataNode("Document");
        IIOMetadataNode node = null; // scratch node

        node = new IIOMetadataNode("FormatVersion");
        node.setAttribute("value", version);
        document_node.appendChild(node);

        // SubimageInterpretation not in format
        // ImageCreationTime not in format
        // ImageModificationTime not in format

        return document_node;
    
public javax.imageio.metadata.IIOMetadataNodegetStandardTextNode()

        // Not in stream
        return null;
    
public javax.imageio.metadata.IIOMetadataNodegetStandardTransparencyNode()

        // Not in stream
        return null;
    
public booleanisReadOnly()

        return true;
    
public voidmergeTree(java.lang.String formatName, org.w3c.dom.Node root)

        throw new IllegalStateException("Metadata is read-only!");
    
public voidreset()

        throw new IllegalStateException("Metadata is read-only!");
    
public voidsetFromTree(java.lang.String formatName, org.w3c.dom.Node root)

        throw new IllegalStateException("Metadata is read-only!");