short[] types = new short[num]; short[] associations = new short[num]; ChannelDefinitionBox.fillBasedOnBands(numComps, isPremultiplied, channels, types, associations); replace("JPEG2000ChannelDefinitionBox", new ChannelDefinitionBox(channels, types, associations));
/** Constructs a <code>ChannelDefinitionBox</code> based on the provided * <code>ColorModel</code>. */ public ChannelDefinitionBox(ColorModel colorModel) { super(computeLength(colorModel), 0x63646566, null); // creates the buffers for the channel definitions. short length = (short)(colorModel.getComponentSize().length - 1); num = (short)(length * (colorModel.isAlphaPremultiplied() ? 3 : 2)); channels = new short[num]; types = new short[num]; associations = new short[num]; // fills the arrays. fillBasedOnBands(length, colorModel.isAlphaPremultiplied(), channels, types, associations); }
if (cdb != null && metadata.getElement("JPEG2000PaletteBox") == null) { short[] assoc = cdb.getAssociation(); short[] types = cdb.getTypes(); short[] channels = cdb.getChannel();
/** Creates an <code>IIOMetadataNode</code> from this channel definition * box. The format of this node is defined in the XML dtd and xsd * for the JP2 image file. */ public IIOMetadataNode getNativeNode() { IIOMetadataNode node = new IIOMetadataNode(Box.getName(getType())); setDefaultAttributes(node); IIOMetadataNode child = new IIOMetadataNode("NumberOfDefinition"); child.setUserObject(new Short(num)); child.setNodeValue("" + num); node.appendChild(child); child = new IIOMetadataNode("Definitions"); node.appendChild(child); for (int i = 0; i < num; i++) { IIOMetadataNode child1 = new IIOMetadataNode("ChannelNumber"); child1.setUserObject(new Short(channels[i])); child1.setNodeValue("" + channels[i]); child.appendChild(child1); child1 = new IIOMetadataNode("ChannelType"); child1.setUserObject(new Short(types[i])); child1.setNodeValue("" + types[i]); child.appendChild(child1); child1 = new IIOMetadataNode("Association"); child1.setUserObject(new Short(associations[i])); child1.setNodeValue("" + associations[i]); child.appendChild(child1); } return node; }
/** * This method reads the Channel Definition box * * @exception java.io.IOException If an I/O error ocurred. * */ public void readChannelDefinitionBox(int length)throws IOException { int num = in.readShort(); channels = new short[num]; cType = new short[num]; associations = new short[num]; for (int i = 0; i < num; i++) { channels[i] = in.readShort(); cType[i] = in.readShort(); associations[i] = in.readShort(); } if (metadata != null) { metadata.addNode(new ChannelDefinitionBox(channels, cType, associations)); } }
protected IIOMetadataNode getStandardTransparencyNode() { ChannelDefinitionBox channel = (ChannelDefinitionBox)getElement("JPEG2000ChannelDefinitionBox"); if (channel != null) { IIOMetadataNode node = new IIOMetadataNode("Transparency"); boolean hasAlpha = false; boolean isPremultiplied = false; short[] type = channel.getTypes(); for (int i = 0; i < type.length; i++) { if (type[i] == 1) hasAlpha = true; if (type[i] == 2) isPremultiplied = true; } String value = "none"; if (isPremultiplied) value = "premultiplied"; else if (hasAlpha) value = "nonpremultiplied"; IIOMetadataNode subNode = new IIOMetadataNode("Alpha"); subNode.setAttribute("value", value); node.appendChild(subNode); return node; } IIOMetadataNode node = new IIOMetadataNode("Transparency"); IIOMetadataNode subNode = new IIOMetadataNode("Alpha"); subNode.setAttribute("value", "none"); node.appendChild(subNode); return null; }
addNode(new ChannelDefinitionBox(colorModel));