FileDocCategorySizeDatePackage
SOSMarkerSegment.javaAPI DocJava SE 5 API8350Fri Aug 26 14:54:42 BST 2005com.sun.imageio.plugins.jpeg

SOSMarkerSegment

public class SOSMarkerSegment extends MarkerSegment
An SOS (Start Of Scan) marker segment.

Fields Summary
int
startSpectralSelection
int
endSpectralSelection
int
approxHigh
int
approxLow
ScanComponentSpec[]
componentSpecs
Constructors Summary
SOSMarkerSegment(boolean willSubsample, byte[] componentIDs, int numComponents)

        super(JPEG.SOS);
        startSpectralSelection = 0;
        endSpectralSelection = 63;
        approxHigh = 0;
        approxLow = 0;
        componentSpecs = new ScanComponentSpec[numComponents];
        for (int i = 0; i < numComponents; i++) {
            int tableSel = 0;
            if (willSubsample) {
                if ((i == 1) || (i == 2)) {
                    tableSel = 1;
                }
            }
            componentSpecs[i] = new ScanComponentSpec(componentIDs[i], 
                                                      tableSel);
        }
    
SOSMarkerSegment(JPEGBuffer buffer)

        super(buffer);
        int numComponents = buffer.buf[buffer.bufPtr++];
        componentSpecs = new ScanComponentSpec[numComponents];
        for (int i = 0; i < numComponents; i++) {
            componentSpecs[i] = new ScanComponentSpec(buffer);
        }
        startSpectralSelection = buffer.buf[buffer.bufPtr++];
        endSpectralSelection = buffer.buf[buffer.bufPtr++];
        approxHigh = buffer.buf[buffer.bufPtr] >> 4;
        approxLow = buffer.buf[buffer.bufPtr++] &0xf;
        buffer.bufAvail -= length;
    
SOSMarkerSegment(Node node)

        super(JPEG.SOS);
        startSpectralSelection = 0;
        endSpectralSelection = 63;
        approxHigh = 0;
        approxLow = 0;
        updateFromNativeNode(node, true);
    
Methods Summary
protected java.lang.Objectclone()

        SOSMarkerSegment newGuy = (SOSMarkerSegment) super.clone();
        if (componentSpecs != null) {
            newGuy.componentSpecs = 
                (ScanComponentSpec []) componentSpecs.clone();
            for (int i = 0; i < componentSpecs.length; i++) {
                newGuy.componentSpecs[i] = 
                    (ScanComponentSpec) componentSpecs[i].clone();
            }
        }
        return newGuy;
    
javax.imageio.metadata.IIOMetadataNodegetNativeNode()

        IIOMetadataNode node = new IIOMetadataNode("sos");
        node.setAttribute("numScanComponents", 
                          Integer.toString(componentSpecs.length));
        node.setAttribute("startSpectralSelection", 
                          Integer.toString(startSpectralSelection));
        node.setAttribute("endSpectralSelection", 
                          Integer.toString(endSpectralSelection));
        node.setAttribute("approxHigh", 
                          Integer.toString(approxHigh));
        node.setAttribute("approxLow", 
                          Integer.toString(approxLow));
        for (int i = 0; i < componentSpecs.length; i++) {
            node.appendChild(componentSpecs[i].getNativeNode());
        }

        return node;
    
com.sun.imageio.plugins.jpeg.SOSMarkerSegment$ScanComponentSpecgetScanComponentSpec(byte componentSel, int tableSel)

        return new ScanComponentSpec(componentSel, tableSel);
    
voidprint()

        printTag("SOS");
        System.out.print("Start spectral selection: ");
        System.out.println(startSpectralSelection);
        System.out.print("End spectral selection: ");
        System.out.println(endSpectralSelection);
        System.out.print("Approx high: ");
        System.out.println(approxHigh);
        System.out.print("Approx low: ");
        System.out.println(approxLow);
        System.out.print("Num scan components: ");
        System.out.println(componentSpecs.length);
        for (int i = 0; i< componentSpecs.length; i++) {
            componentSpecs[i].print();
        }
    
voidupdateFromNativeNode(org.w3c.dom.Node node, boolean fromScratch)

        NamedNodeMap attrs = node.getAttributes();
        int numComponents = getAttributeValue(node, attrs, "numScanComponents",
                                              1, 4, true);
        int value = getAttributeValue(node, attrs, "startSpectralSelection",
                                      0, 63, false);
        startSpectralSelection = (value != -1) ? value : startSpectralSelection;
        value = getAttributeValue(node, attrs, "endSpectralSelection",
                                  0, 63, false);
        endSpectralSelection = (value != -1) ? value : endSpectralSelection;
        value = getAttributeValue(node, attrs, "approxHigh", 0, 15, false);
        approxHigh = (value != -1) ? value : approxHigh;
        value = getAttributeValue(node, attrs, "approxLow", 0, 15, false);
        approxLow = (value != -1) ? value : approxLow;

        // Now the children
        NodeList children = node.getChildNodes();
        if (children.getLength() != numComponents) {
            throw new IIOInvalidTreeException
                ("numScanComponents must match the number of children", node);
        }
        componentSpecs = new ScanComponentSpec[numComponents];
        for (int i = 0; i < numComponents; i++) {
            componentSpecs[i] = new ScanComponentSpec(children.item(i));
        }
    
voidwrite(javax.imageio.stream.ImageOutputStream ios)
Writes the data for this segment to the stream in valid JPEG format.

        // We don't write SOS segments; the IJG library does.