}
return numChannels;
}
public IIOMetadataNode getStandardChromaNode() {
IIOMetadataNode chroma_node = new IIOMetadataNode("Chroma");
IIOMetadataNode node = null; // scratch node
node = new IIOMetadataNode("ColorSpaceType");
node.setAttribute("name", colorSpaceTypeNames[IHDR_colorType]);
chroma_node.appendChild(node);
node = new IIOMetadataNode("NumChannels");
node.setAttribute("value", Integer.toString(getNumChannels()));
chroma_node.appendChild(node);
if (gAMA_present) {
node = new IIOMetadataNode("Gamma");
node.setAttribute("value", Float.toString(gAMA_gamma*1.0e-5F));
chroma_node.appendChild(node);
}
node = new IIOMetadataNode("BlackIsZero");
node.setAttribute("value", "true");
chroma_node.appendChild(node);
if (PLTE_present) {
boolean hasAlpha = tRNS_present &&
(tRNS_colorType == PNGImageReader.PNG_COLOR_PALETTE);
node = new IIOMetadataNode("Palette");
for (int i = 0; i < PLTE_red.length; i++) {
IIOMetadataNode entry =
new IIOMetadataNode("PaletteEntry");
entry.setAttribute("index", Integer.toString(i));
entry.setAttribute("red",
Integer.toString(PLTE_red[i] & 0xff));
entry.setAttribute("green",
Integer.toString(PLTE_green[i] & 0xff));
entry.setAttribute("blue",
Integer.toString(PLTE_blue[i] & 0xff));
if (hasAlpha) {
int alpha = (i < tRNS_alpha.length) ?
(tRNS_alpha[i] & 0xff) : 255;
entry.setAttribute("alpha", Integer.toString(alpha));
}
node.appendChild(entry);
}
chroma_node.appendChild(node);
}
if (bKGD_present) {
if (bKGD_colorType == PNGImageReader.PNG_COLOR_PALETTE) {
node = new IIOMetadataNode("BackgroundIndex");
node.setAttribute("value", Integer.toString(bKGD_index));
} else {
node = new IIOMetadataNode("BackgroundColor");
int r, g, b;
if (bKGD_colorType == PNGImageReader.PNG_COLOR_GRAY) {
r = g = b = bKGD_gray;
} else {