use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class MarkerSegment method getNativeNode.
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("unknown");
node.setAttribute("MarkerTag", Integer.toString(tag));
node.setUserObject(data);
return node;
}
use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class PNGMetadata method getStandardCompressionNode.
public IIOMetadataNode getStandardCompressionNode() {
IIOMetadataNode compression_node = new IIOMetadataNode("Compression");
// scratch node
IIOMetadataNode node = null;
node = new IIOMetadataNode("CompressionTypeName");
node.setAttribute("value", "deflate");
compression_node.appendChild(node);
node = new IIOMetadataNode("Lossless");
node.setAttribute("value", "TRUE");
compression_node.appendChild(node);
node = new IIOMetadataNode("NumProgressiveScans");
node.setAttribute("value", (IHDR_interlaceMethod == 0) ? "1" : "7");
compression_node.appendChild(node);
return compression_node;
}
use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class JPEGMetadata method getNativeTree.
IIOMetadataNode getNativeTree() {
IIOMetadataNode root;
IIOMetadataNode top;
Iterator iter = markerSequence.iterator();
if (isStream) {
root = new IIOMetadataNode(JPEG.nativeStreamMetadataFormatName);
top = root;
} else {
IIOMetadataNode sequence = new IIOMetadataNode("markerSequence");
if (!inThumb) {
root = new IIOMetadataNode(JPEG.nativeImageMetadataFormatName);
IIOMetadataNode header = new IIOMetadataNode("JPEGvariety");
root.appendChild(header);
JFIFMarkerSegment jfif = (JFIFMarkerSegment) findMarkerSegment(JFIFMarkerSegment.class, true);
if (jfif != null) {
// JFIF must be first, so this skips it
iter.next();
header.appendChild(jfif.getNativeNode());
}
root.appendChild(sequence);
} else {
root = sequence;
}
top = sequence;
}
while (iter.hasNext()) {
MarkerSegment seg = (MarkerSegment) iter.next();
top.appendChild(seg.getNativeNode());
}
return root;
}
use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class JPEGMetadata method getStandardChromaNode.
// Standard tree node methods
protected IIOMetadataNode getStandardChromaNode() {
// Unless we find otherwise
hasAlpha = false;
// Colorspace type - follow the rules in the spec
// First get the SOF marker segment, if there is one
SOFMarkerSegment sof = (SOFMarkerSegment) findMarkerSegment(SOFMarkerSegment.class, true);
if (sof == null) {
// No image, so no chroma
return null;
}
IIOMetadataNode chroma = new IIOMetadataNode("Chroma");
IIOMetadataNode csType = new IIOMetadataNode("ColorSpaceType");
chroma.appendChild(csType);
// get the number of channels
int numChannels = sof.componentSpecs.length;
IIOMetadataNode numChanNode = new IIOMetadataNode("NumChannels");
chroma.appendChild(numChanNode);
numChanNode.setAttribute("value", Integer.toString(numChannels));
// is there a JFIF marker segment?
if (findMarkerSegment(JFIFMarkerSegment.class, true) != null) {
if (numChannels == 1) {
csType.setAttribute("name", "GRAY");
} else {
csType.setAttribute("name", "YCbCr");
}
return chroma;
}
// How about an Adobe marker segment?
AdobeMarkerSegment adobe = (AdobeMarkerSegment) findMarkerSegment(AdobeMarkerSegment.class, true);
if (adobe != null) {
switch(adobe.transform) {
case JPEG.ADOBE_YCCK:
csType.setAttribute("name", "YCCK");
break;
case JPEG.ADOBE_YCC:
csType.setAttribute("name", "YCbCr");
break;
case JPEG.ADOBE_UNKNOWN:
if (numChannels == 3) {
csType.setAttribute("name", "RGB");
} else if (numChannels == 4) {
csType.setAttribute("name", "CMYK");
}
break;
}
return chroma;
}
// Neither marker. Check components
if (numChannels < 3) {
csType.setAttribute("name", "GRAY");
if (numChannels == 2) {
hasAlpha = true;
}
return chroma;
}
boolean idsAreJFIF = true;
for (int i = 0; i < sof.componentSpecs.length; i++) {
int id = sof.componentSpecs[i].componentId;
if ((id < 1) || (id >= sof.componentSpecs.length)) {
idsAreJFIF = false;
}
}
if (idsAreJFIF) {
csType.setAttribute("name", "YCbCr");
if (numChannels == 4) {
hasAlpha = true;
}
return chroma;
}
// Check against the letters
if ((sof.componentSpecs[0].componentId == 'R') && (sof.componentSpecs[1].componentId == 'G') && (sof.componentSpecs[2].componentId == 'B')) {
csType.setAttribute("name", "RGB");
if ((numChannels == 4) && (sof.componentSpecs[3].componentId == 'A')) {
hasAlpha = true;
}
return chroma;
}
if ((sof.componentSpecs[0].componentId == 'Y') && (sof.componentSpecs[1].componentId == 'C') && (sof.componentSpecs[2].componentId == 'c')) {
csType.setAttribute("name", "PhotoYCC");
if ((numChannels == 4) && (sof.componentSpecs[3].componentId == 'A')) {
hasAlpha = true;
}
return chroma;
}
// Finally, 3-channel subsampled are YCbCr, unsubsampled are RGB
// 4-channel subsampled are YCbCrA, unsubsampled are CMYK
boolean subsampled = false;
int hfactor = sof.componentSpecs[0].HsamplingFactor;
int vfactor = sof.componentSpecs[0].VsamplingFactor;
for (int i = 1; i < sof.componentSpecs.length; i++) {
if ((sof.componentSpecs[i].HsamplingFactor != hfactor) || (sof.componentSpecs[i].VsamplingFactor != vfactor)) {
subsampled = true;
break;
}
}
if (subsampled) {
csType.setAttribute("name", "YCbCr");
if (numChannels == 4) {
hasAlpha = true;
}
return chroma;
}
// Not subsampled. numChannels < 3 is taken care of above
if (numChannels == 3) {
csType.setAttribute("name", "RGB");
} else {
csType.setAttribute("name", "CMYK");
}
return chroma;
}
use of javax.imageio.metadata.IIOMetadataNode in project jdk8u_jdk by JetBrains.
the class DQTMarkerSegment method getNativeNode.
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("dqt");
for (int i = 0; i < tables.size(); i++) {
Qtable table = (Qtable) tables.get(i);
node.appendChild(table.getNativeNode());
}
return node;
}
Aggregations