Java Code Examples for javax.imageio.metadata.IIOMetadataNode#appendChild()
The following examples show how to use
javax.imageio.metadata.IIOMetadataNode#appendChild() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JFIFMarkerSegment.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Returns a tree of DOM nodes representing this object and any * subordinate JFXX extension or ICC Profile segments. */ IIOMetadataNode getNativeNode() { IIOMetadataNode node = new IIOMetadataNode("app0JFIF"); node.setAttribute("majorVersion", Integer.toString(majorVersion)); node.setAttribute("minorVersion", Integer.toString(minorVersion)); node.setAttribute("resUnits", Integer.toString(resUnits)); node.setAttribute("Xdensity", Integer.toString(Xdensity)); node.setAttribute("Ydensity", Integer.toString(Ydensity)); node.setAttribute("thumbWidth", Integer.toString(thumbWidth)); node.setAttribute("thumbHeight", Integer.toString(thumbHeight)); if (!extSegments.isEmpty()) { IIOMetadataNode JFXXnode = new IIOMetadataNode("JFXX"); node.appendChild(JFXXnode); for (Iterator iter = extSegments.iterator(); iter.hasNext();) { JFIFExtensionMarkerSegment seg = (JFIFExtensionMarkerSegment) iter.next(); JFXXnode.appendChild(seg.getNativeNode()); } } if (iccSegment != null) { node.appendChild(iccSegment.getNativeNode()); } return node; }
Example 2
Source File: SOFMarkerSegment.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example 3
Source File: SOFMarkerSegment.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example 4
Source File: SOSMarkerSegment.java From JDKSourceCode1.8 with MIT License | 6 votes |
IIOMetadataNode getNativeNode() { IIOMetadataNode node = new IIOMetadataNode("sos"); node.setAttribute("numScanComponents", Integer.toString(componentSpecs.length)); node.setAttribute("startSpectralSelection", Integer.toString(startSpectralSelection)); node.setAttribute("endSpectralSelection", Integer.toString(endSpectralSelection)); node.setAttribute("approxHigh", Integer.toString(approxHigh)); node.setAttribute("approxLow", Integer.toString(approxLow)); for (int i = 0; i < componentSpecs.length; i++) { node.appendChild(componentSpecs[i].getNativeNode()); } return node; }
Example 5
Source File: BMPMetadata.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
protected IIOMetadataNode getStandardDataNode() { IIOMetadataNode node = new IIOMetadataNode("Data"); String bits = ""; if (bitsPerPixel == 24) bits = "8 8 8 "; else if (bitsPerPixel == 16 || bitsPerPixel == 32) { bits = "" + countBits(redMask) + " " + countBits(greenMask) + countBits(blueMask) + "" + countBits(alphaMask); } IIOMetadataNode subNode = new IIOMetadataNode("BitsPerSample"); subNode.setAttribute("value", bits); node.appendChild(subNode); return node; }
Example 6
Source File: LegendManager.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Sets the dpi. * * @param metadata the metadata * @param dpi the dpi * @throws IIOInvalidTreeException the IIO invalid tree exception */ private void setDPI(IIOMetadata metadata, int dpi) throws IIOInvalidTreeException { // for PNG, it's dots per millimeter double dotsPerMilli = 1.0 * dpi / 10 / INCH_2_CM; IIOMetadataNode horiz = new IIOMetadataNode("HorizontalPixelSize"); horiz.setAttribute("value", Double.toString(dotsPerMilli)); IIOMetadataNode vert = new IIOMetadataNode("VerticalPixelSize"); vert.setAttribute("value", Double.toString(dotsPerMilli)); IIOMetadataNode dim = new IIOMetadataNode("Dimension"); dim.appendChild(horiz); dim.appendChild(vert); IIOMetadataNode root = new IIOMetadataNode("javax_imageio_1.0"); root.appendChild(dim); metadata.mergeTree("javax_imageio_1.0", root); }
Example 7
Source File: TIFFImageMetadata.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private Node getNativeTree() { IIOMetadataNode root = new IIOMetadataNode(nativeMetadataFormatName); Node IFDNode = getIFDAsTree(rootIFD, null, 0); root.appendChild(IFDNode); return root; }
Example 8
Source File: DHTMarkerSegment.java From Bytecoder with Apache License 2.0 | 5 votes |
IIOMetadataNode getNativeNode() { IIOMetadataNode node = new IIOMetadataNode("dht"); for (int i= 0; i<tables.size(); i++) { Htable table = tables.get(i); node.appendChild(table.getNativeNode()); } return node; }
Example 9
Source File: JFIFMarkerSegment.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
IIOMetadataNode getNativeNode() { IIOMetadataNode node = new IIOMetadataNode("JFIFthumbJPEG"); if (thumbMetadata != null) { node.appendChild(thumbMetadata.getNativeTree()); } return node; }
Example 10
Source File: JPEGMetadata.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
protected IIOMetadataNode getStandardCompressionNode() { IIOMetadataNode compression = new IIOMetadataNode("Compression"); // CompressionTypeName IIOMetadataNode name = new IIOMetadataNode("CompressionTypeName"); name.setAttribute("value", "JPEG"); compression.appendChild(name); // Lossless - false IIOMetadataNode lossless = new IIOMetadataNode("Lossless"); lossless.setAttribute("value", "FALSE"); compression.appendChild(lossless); // NumProgressiveScans - count sos segments int sosCount = 0; Iterator iter = markerSequence.iterator(); while (iter.hasNext()) { MarkerSegment ms = (MarkerSegment) iter.next(); if (ms.tag == JPEG.SOS) { sosCount++; } } if (sosCount != 0) { IIOMetadataNode prog = new IIOMetadataNode("NumProgressiveScans"); prog.setAttribute("value", Integer.toString(sosCount)); compression.appendChild(prog); } return compression; }
Example 11
Source File: JPEGMetadata.java From JDKSourceCode1.8 with MIT License | 5 votes |
protected IIOMetadataNode getStandardCompressionNode() { IIOMetadataNode compression = new IIOMetadataNode("Compression"); // CompressionTypeName IIOMetadataNode name = new IIOMetadataNode("CompressionTypeName"); name.setAttribute("value", "JPEG"); compression.appendChild(name); // Lossless - false IIOMetadataNode lossless = new IIOMetadataNode("Lossless"); lossless.setAttribute("value", "FALSE"); compression.appendChild(lossless); // NumProgressiveScans - count sos segments int sosCount = 0; Iterator iter = markerSequence.iterator(); while (iter.hasNext()) { MarkerSegment ms = (MarkerSegment) iter.next(); if (ms.tag == JPEG.SOS) { sosCount++; } } if (sosCount != 0) { IIOMetadataNode prog = new IIOMetadataNode("NumProgressiveScans"); prog.setAttribute("value", Integer.toString(sosCount)); compression.appendChild(prog); } return compression; }
Example 12
Source File: DHTMarkerSegment.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
IIOMetadataNode getNativeNode() { IIOMetadataNode node = new IIOMetadataNode("dht"); for (int i= 0; i<tables.size(); i++) { Htable table = (Htable) tables.get(i); node.appendChild(table.getNativeNode()); } return node; }
Example 13
Source File: BMPMetadata.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private IIOMetadataNode addChildNode(IIOMetadataNode root, String name, Object object) { IIOMetadataNode child = new IIOMetadataNode(name); if (object != null) { child.setUserObject(object); child.setNodeValue(ImageUtil.convertObjectToString(object)); } root.appendChild(child); return child; }
Example 14
Source File: WBMPMetadata.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
protected IIOMetadataNode getStandardChromaNode() { IIOMetadataNode node = new IIOMetadataNode("Chroma"); IIOMetadataNode subNode = new IIOMetadataNode("BlackIsZero"); subNode.setAttribute("value", "TRUE"); node.appendChild(subNode); return node; }
Example 15
Source File: BMPMetadata.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private IIOMetadataNode addChildNode(IIOMetadataNode root, String name, Object object) { IIOMetadataNode child = new IIOMetadataNode(name); if (object != null) { child.setUserObject(object); child.setNodeValue(ImageUtil.convertObjectToString(object)); } root.appendChild(child); return child; }
Example 16
Source File: WBMPMetadata.java From hottub with GNU General Public License v2.0 | 5 votes |
private IIOMetadataNode addChildNode(IIOMetadataNode root, String name, Object object) { IIOMetadataNode child = new IIOMetadataNode(name); if (object != null) { child.setUserObject(object); child.setNodeValue(ImageUtil.convertObjectToString(object)); } root.appendChild(child); return child; }
Example 17
Source File: BMPMetadata.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private IIOMetadataNode addChildNode(IIOMetadataNode root, String name, Object object) { IIOMetadataNode child = new IIOMetadataNode(name); if (object != null) { child.setUserObject(object); child.setNodeValue(ImageUtil.convertObjectToString(object)); } root.appendChild(child); return child; }
Example 18
Source File: WBMPMetadata.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private IIOMetadataNode addChildNode(IIOMetadataNode root, String name, Object object) { IIOMetadataNode child = new IIOMetadataNode(name); if (object != null) { child.setUserObject(object); child.setNodeValue(ImageUtil.convertObjectToString(object)); } root.appendChild(child); return child; }
Example 19
Source File: JPEGMetadata.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
protected IIOMetadataNode getStandardDimensionNode() { // If we have a JFIF marker segment, we know a little // otherwise all we know is the orientation, which is always normal IIOMetadataNode dim = new IIOMetadataNode("Dimension"); IIOMetadataNode orient = new IIOMetadataNode("ImageOrientation"); orient.setAttribute("value", "normal"); dim.appendChild(orient); JFIFMarkerSegment jfif = (JFIFMarkerSegment) findMarkerSegment(JFIFMarkerSegment.class, true); if (jfif != null) { // Aspect Ratio is width of pixel / height of pixel float aspectRatio; if (jfif.resUnits == 0) { // In this case they just encode aspect ratio directly aspectRatio = ((float) jfif.Xdensity)/jfif.Ydensity; } else { // They are true densities (e.g. dpi) and must be inverted aspectRatio = ((float) jfif.Ydensity)/jfif.Xdensity; } IIOMetadataNode aspect = new IIOMetadataNode("PixelAspectRatio"); aspect.setAttribute("value", Float.toString(aspectRatio)); dim.insertBefore(aspect, orient); // Pixel size if (jfif.resUnits != 0) { // 1 == dpi, 2 == dpc float scale = (jfif.resUnits == 1) ? 25.4F : 10.0F; IIOMetadataNode horiz = new IIOMetadataNode("HorizontalPixelSize"); horiz.setAttribute("value", Float.toString(scale/jfif.Xdensity)); dim.appendChild(horiz); IIOMetadataNode vert = new IIOMetadataNode("VerticalPixelSize"); vert.setAttribute("value", Float.toString(scale/jfif.Ydensity)); dim.appendChild(vert); } } return dim; }
Example 20
Source File: JPEGMetadata.java From Bytecoder with Apache License 2.0 | 4 votes |
protected IIOMetadataNode getStandardDimensionNode() { // If we have a JFIF marker segment, we know a little // otherwise all we know is the orientation, which is always normal IIOMetadataNode dim = new IIOMetadataNode("Dimension"); IIOMetadataNode orient = new IIOMetadataNode("ImageOrientation"); orient.setAttribute("value", "normal"); dim.appendChild(orient); JFIFMarkerSegment jfif = (JFIFMarkerSegment) findMarkerSegment(JFIFMarkerSegment.class, true); if (jfif != null) { // Aspect Ratio is width of pixel / height of pixel float aspectRatio; if (jfif.resUnits == 0) { // In this case they just encode aspect ratio directly aspectRatio = ((float) jfif.Xdensity)/jfif.Ydensity; } else { // They are true densities (e.g. dpi) and must be inverted aspectRatio = ((float) jfif.Ydensity)/jfif.Xdensity; } IIOMetadataNode aspect = new IIOMetadataNode("PixelAspectRatio"); aspect.setAttribute("value", Float.toString(aspectRatio)); dim.insertBefore(aspect, orient); // Pixel size if (jfif.resUnits != 0) { // 1 == dpi, 2 == dpc float scale = (jfif.resUnits == 1) ? 25.4F : 10.0F; IIOMetadataNode horiz = new IIOMetadataNode("HorizontalPixelSize"); horiz.setAttribute("value", Float.toString(scale/jfif.Xdensity)); dim.appendChild(horiz); IIOMetadataNode vert = new IIOMetadataNode("VerticalPixelSize"); vert.setAttribute("value", Float.toString(scale/jfif.Ydensity)); dim.appendChild(vert); } } return dim; }