SOFMarkerSegmentpublic class SOFMarkerSegment extends MarkerSegment An SOF (Start Of Frame) marker segment. |
Fields Summary |
---|
int | samplePrecision | int | numLines | int | samplesPerLine | ComponentSpec[] | componentSpecs |
Constructors Summary |
---|
SOFMarkerSegment(boolean wantProg, boolean wantExtended, boolean willSubsample, byte[] componentIDs, int numComponents)
super(wantProg ? JPEG.SOF2
: wantExtended ? JPEG.SOF1
: JPEG.SOF0);
samplePrecision = 8;
numLines = 0;
samplesPerLine = 0;
componentSpecs = new ComponentSpec[numComponents];
for(int i = 0; i < numComponents; i++) {
int factor = 1;
int qsel = 0;
if (willSubsample) {
factor = 2;
if ((i == 1) || (i == 2)) {
factor = 1;
qsel = 1;
}
}
componentSpecs[i] = new ComponentSpec(componentIDs[i], factor, qsel);
}
| SOFMarkerSegment(JPEGBuffer buffer)
super(buffer);
samplePrecision = buffer.buf[buffer.bufPtr++];
numLines = (buffer.buf[buffer.bufPtr++] & 0xff) << 8;
numLines |= buffer.buf[buffer.bufPtr++] & 0xff;
samplesPerLine = (buffer.buf[buffer.bufPtr++] & 0xff) << 8;
samplesPerLine |= buffer.buf[buffer.bufPtr++] & 0xff;
int numComponents = buffer.buf[buffer.bufPtr++];
componentSpecs = new ComponentSpec [numComponents];
for (int i = 0; i < numComponents; i++) {
componentSpecs[i] = new ComponentSpec(buffer);
}
buffer.bufAvail -= length;
| SOFMarkerSegment(Node node)
// All attributes are optional, so setup defaults first
super(JPEG.SOF0);
samplePrecision = 8;
numLines = 0;
samplesPerLine = 0;
updateFromNativeNode(node, true);
|
Methods Summary |
---|
protected java.lang.Object | clone()
SOFMarkerSegment newGuy = (SOFMarkerSegment) super.clone();
if (componentSpecs != null) {
newGuy.componentSpecs = (ComponentSpec []) componentSpecs.clone();
for (int i = 0; i < componentSpecs.length; i++) {
newGuy.componentSpecs[i] =
(ComponentSpec) componentSpecs[i].clone();
}
}
return newGuy;
| com.sun.imageio.plugins.jpeg.SOFMarkerSegment$ComponentSpec | getComponentSpec(byte id, int factor, int qSelector)
return new ComponentSpec(id, factor, qSelector);
| int | getIDencodedCSType()
for (int i = 0; i < componentSpecs.length; i++) {
if (componentSpecs[i].componentId < 'A") {
return JPEG.JCS_UNKNOWN;
}
}
switch(componentSpecs.length) {
case 3:
if ((componentSpecs[0].componentId == 'R")
&&(componentSpecs[0].componentId == 'G")
&&(componentSpecs[0].componentId == 'B")) {
return JPEG.JCS_RGB;
}
if ((componentSpecs[0].componentId == 'Y")
&&(componentSpecs[0].componentId == 'C")
&&(componentSpecs[0].componentId == 'c")) {
return JPEG.JCS_YCC;
}
break;
case 4:
if ((componentSpecs[0].componentId == 'R")
&&(componentSpecs[0].componentId == 'G")
&&(componentSpecs[0].componentId == 'B")
&&(componentSpecs[0].componentId == 'A")) {
return JPEG.JCS_RGBA;
}
if ((componentSpecs[0].componentId == 'Y")
&&(componentSpecs[0].componentId == 'C")
&&(componentSpecs[0].componentId == 'c")
&&(componentSpecs[0].componentId == 'A")) {
return JPEG.JCS_YCCA;
}
}
return JPEG.JCS_UNKNOWN;
| javax.imageio.metadata.IIOMetadataNode | getNativeNode()
IIOMetadataNode node = new IIOMetadataNode("sof");
node.setAttribute("process", Integer.toString(tag-JPEG.SOF0));
node.setAttribute("samplePrecision",
Integer.toString(samplePrecision));
node.setAttribute("numLines",
Integer.toString(numLines));
node.setAttribute("samplesPerLine",
Integer.toString(samplesPerLine));
node.setAttribute("numFrameComponents",
Integer.toString(componentSpecs.length));
for (int i = 0; i < componentSpecs.length; i++) {
node.appendChild(componentSpecs[i].getNativeNode());
}
return node;
| void | print()
printTag("SOF");
System.out.print("Sample precision: ");
System.out.println(samplePrecision);
System.out.print("Number of lines: ");
System.out.println(numLines);
System.out.print("Samples per line: ");
System.out.println(samplesPerLine);
System.out.print("Number of components: ");
System.out.println(componentSpecs.length);
for(int i = 0; i<componentSpecs.length; i++) {
componentSpecs[i].print();
}
| void | updateFromNativeNode(org.w3c.dom.Node node, boolean fromScratch)
NamedNodeMap attrs = node.getAttributes();
int value = getAttributeValue(node, attrs, "process", 0, 2, false);
tag = (value != -1) ? value+JPEG.SOF0 : tag;
// If samplePrecision is present, it must be 8.
// This just checks. We don't bother to assign the value.
value = getAttributeValue(node, attrs, "samplePrecision", 8, 8, false);
value = getAttributeValue(node, attrs, "numLines", 0, 65535, false);
numLines = (value != -1) ? value : numLines;
value = getAttributeValue(node, attrs, "samplesPerLine", 0, 65535, false);
samplesPerLine = (value != -1) ? value : samplesPerLine;
int numComponents = getAttributeValue(node, attrs, "numFrameComponents",
1, 4, false);
NodeList children = node.getChildNodes();
if (children.getLength() != numComponents) {
throw new IIOInvalidTreeException
("numFrameComponents must match number of children", node);
}
componentSpecs = new ComponentSpec [numComponents];
for (int i = 0; i < numComponents; i++) {
componentSpecs[i] = new ComponentSpec(children.item(i));
}
| void | write(javax.imageio.stream.ImageOutputStream ios)Writes the data for this segment to the stream in
valid JPEG format.
// We don't write SOF segments; the IJG library does.
|
|