return (IIOMetadata)((J2KMetadata)inData).clone(); J2KMetadata outData = new J2KMetadata(); outData.setFromTree(format, inData.getAsTree(format)); return outData;
public Object clone() { J2KMetadata theClone = null; try { theClone = (J2KMetadata) super.clone(); } catch (CloneNotSupportedException e) {} // won't happen if (boxes != null) { int numBoxes = boxes.size(); for(int i = 0; i < numBoxes; i++) { theClone.addNode((Box)boxes.get(i)); } } return theClone; }
private IIOMetadataNode getNodeFromTree(IIOMetadataNode root, String name, String childName) { if (name.equals(root.getNodeName())) return root; NodeList list = root.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { IIOMetadataNode node = (IIOMetadataNode)list.item(i); if (node.getNodeName().equals(name)) { if (name.equals("JPEG2000UUIDInfoBox") && checkUUIDInfoBox(node, childName)) continue; else return node; } node = getNodeFromTree(node, name, childName); if (node != null) return node; } return null; }
private IIOMetadataNode createNodeIntoTree(IIOMetadataNode root, String name) { IIOMetadataNode node = getNodeFromTree(root, name, null); if (node != null) return node; node = new IIOMetadataNode(name); String parent = format.getParent(name); IIOMetadataNode parentNode = createNodeIntoTree(root, parent); parentNode.appendChild(node); return node; }
createColorSpecificationBoxFromStandardNode(child); createPaletteBoxFromStandardNode(child); createBitsPerComponentBoxFromStandardNode(node); createHeaderBoxFromStandardNode(node, numComps); } else if (name.equals("Dimension")) { createResolutionBoxFromStandardNode(node); } else if (name.equals("Document")) { createXMLBoxFromStandardNode(node); } else if (name.equals("Text")) { createXMLBoxFromStandardNode(node); } else if (name.equals("Transparency")) { createChannelDefinitionFromStandardNode(node); } else { throw new IIOInvalidTreeException(I18N.getString("J2KMetadata3")
IIOMetadata inMetadata = image.getMetadata(); J2KMetadata metadata1 = new J2KMetadata(colorModel, sampleModel, imgsrc.getImgWidth(), metadata = new J2KMetadata(); if(metaFormat != null) { metadata.setFromTree(metaFormat, inMetadata.getAsTree(metaFormat)); metadata.mergeTree(J2KMetadata.nativeMetadataFormatName, metadata1.getAsTree(J2KMetadata.nativeMetadataFormatName));
ImageWriter writer) { this(); addNode(new SignatureBox()); addNode(new FileTypeBox(0x6A703220, 0, new int[]{0x6A703220})); addNode(new ColorSpecificationBox((byte)1, (byte)0, (byte)0, ColorSpecificationBox.ECS_sRGB, null)); } else if (type == ColorSpace.TYPE_GRAY) addNode(new ColorSpecificationBox((byte)1, (byte)0, (byte)0, ColorSpecificationBox.ECS_GRAY, null)); else if (cs instanceof ICC_ColorSpace) addNode(new ColorSpecificationBox((byte)2, (byte)0, (byte)0, 0, addNode(new ChannelDefinitionBox(colorModel)); addNode(new PaletteBox((IndexColorModel)colorModel)); int numComp = colorModel.getComponentSize().length; short[] channels = new short[numComp]; addNode(new ComponentMappingBox(channels, types, maps)); int bpc = bitsPerComponent == 0xff ? 0xff : ((bitsPerComponent - 1) |
public IIOMetadata getDefaultImageMetadata(ImageTypeSpecifier imageType, ImageWriteParam param) { return new J2KMetadata(imageType, param, this); }
private boolean insertNodeIntoTree(IIOMetadataNode root, IIOMetadataNode node) { String name = node.getNodeName(); String parent = format.getParent(name); if (parent == null) return false; IIOMetadataNode parentNode = getNodeFromTree(root, parent, name); if (parentNode == null) parentNode = createNodeIntoTree(root, parent); parentNode.appendChild(node); return true; }
public IIOMetadata getImageMetadata(int imageIndex) throws IOException { checkIndex(imageIndex); if (ignoreMetadata) return null; if (imageMetadata == null) { iis.mark(); imageMetadata = new J2KMetadata(iis, this); iis.reset(); } return imageMetadata; }
/** Read the bits per component. */ public void readBitsPerComponentBox(int length)throws IOException { bitDepths = new byte[length]; in.readFully(bitDepths, 0, length); if (metadata != null) { metadata.addNode(new BitsPerComponentBox(bitDepths)); } }
public RenderedImage readAsRenderedImage(int imageIndex, ImageReadParam param) throws IOException { checkIndex(imageIndex); RenderedImage ri = null; clearAbortRequest(); processImageStarted(imageIndex); if (param == null) param = getDefaultReadParam(); param = new J2KImageReadParamJava(param); if (!ignoreMetadata) { if (imageMetadata == null) imageMetadata = new J2KMetadata(); ri = new J2KRenderedImage(iis, (J2KImageReadParamJava)param, imageMetadata, this); } else ri = new J2KRenderedImage(iis, (J2KImageReadParamJava)param, this); if (abortRequested()) processReadAborted(); else processImageComplete(); return ri; }
/** * This method reads the contents of the XML box */ public void readXMLBox(int length) throws IOException { if (metadata != null) { byte[] data = new byte[length]; in.readFully(data, 0, length); metadata.addNode(new XMLBox(data)); } }
public Raster readRaster(int imageIndex, ImageReadParam param) throws IOException { checkIndex(imageIndex); processImageStarted(imageIndex); if (param == null) { param = getDefaultReadParam(); } param = new J2KImageReadParamJava(param); if (!ignoreMetadata) { imageMetadata = new J2KMetadata(); iis.seek(streamPosition0); readState = new J2KReadState(iis, (J2KImageReadParamJava)param, imageMetadata, this); } else { iis.seek(streamPosition0); readState = new J2KReadState(iis, (J2KImageReadParamJava)param, this); } Raster ras = readState.readAsRaster(); if (abortRequested()) processReadAborted(); else processImageComplete(); return ras; }
/** * This method reads the contents of the Intellectual property box * */ public void readIntPropertyBox(int length) throws IOException { if (metadata != null) { byte[] data = new byte[length]; in.readFully(data, 0, length); metadata.addNode(new Box(length + 8, 0x6A703269, data)); } }
public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException { checkIndex(imageIndex); clearAbortRequest(); processImageStarted(imageIndex); if (param == null) param = getDefaultReadParam(); param = new J2KImageReadParamJava(param); if (!ignoreMetadata) { imageMetadata = new J2KMetadata(); iis.seek(streamPosition0); readState = new J2KReadState(iis, (J2KImageReadParamJava)param, imageMetadata, this); } else { iis.seek(streamPosition0); readState = new J2KReadState(iis, (J2KImageReadParamJava)param, this); } BufferedImage bi = readState.readBufferedImage(); if (abortRequested()) processReadAborted(); else processImageComplete(); return bi; }
/** * This method reads the contents of the XML box */ public void readURLBox(int length) throws IOException { if (metadata != null) { byte[] data = new byte[length]; in.readFully(data, 0, length); metadata.addNode(new DataEntryURLBox(data)); } }
/** * This method reads the contents of the Intellectual property box */ public void readUUIDBox(int length) throws IOException { if (metadata != null) { byte[] data = new byte[length]; in.readFully(data, 0, length); metadata.addNode(new UUIDBox(data)); } }
/** * This method reads the contents of the UUID List box * */ public void readUUIDListBox(int length) throws IOException { if (metadata != null) { byte[] data = new byte[length]; in.readFully(data, 0, length); metadata.addNode(new UUIDListBox(data)); } }
/** Read the resolution. */ public void readResolutionBox(int type, int length)throws IOException { byte[] data = new byte[length]; in.readFully(data, 0, length); if (metadata != null) { metadata.addNode(new ResolutionBox(type, data)); } }