You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by ca...@apache.org on 2007/01/16 02:17:02 UTC
svn commit: r496561 - in
/xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics:
image/writer/imageio/ util/
Author: cam
Date: Mon Jan 15 17:17:01 2007
New Revision: 496561
URL: http://svn.apache.org/viewvc?view=rev&rev=496561
Log:
Fix some svn:executable and svn:eol-style properties.
Modified:
xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java (contents, props changed)
xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java (contents, props changed)
xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOPNGImageWriter.java (contents, props changed)
xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java (contents, props changed)
xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/util/ImageIODebugUtil.java (contents, props changed)
Modified: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java?view=diff&rev=496561&r1=496560&r2=496561
==============================================================================
--- xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java (original)
+++ xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java Mon Jan 15 17:17:01 2007
@@ -1,289 +1,289 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.xmlgraphics.image.writer.imageio;
-
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Iterator;
-
-import javax.imageio.IIOImage;
-import javax.imageio.ImageIO;
-import javax.imageio.ImageTypeSpecifier;
-import javax.imageio.ImageWriteParam;
-import javax.imageio.event.IIOWriteWarningListener;
-import javax.imageio.metadata.IIOInvalidTreeException;
-import javax.imageio.metadata.IIOMetadata;
-import javax.imageio.metadata.IIOMetadataNode;
-import javax.imageio.stream.ImageOutputStream;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.apache.xmlgraphics.image.writer.ImageWriter;
-import org.apache.xmlgraphics.image.writer.ImageWriterParams;
-import org.apache.xmlgraphics.image.writer.MultiImageWriter;
-
-/**
- * ImageWriter implementation that uses Image I/O to write images.
- *
- * @version $Id$
- */
-public class ImageIOImageWriter implements ImageWriter, IIOWriteWarningListener {
-
- private static final String STANDARD_METADATA_FORMAT = "javax_imageio_1.0";
-
- private String targetMIME;
-
- /**
- * Main constructor.
- * @param mime the MIME type of the image format
- */
- public ImageIOImageWriter(String mime) {
- this.targetMIME = mime;
- }
-
- /**
- * @see ImageWriter#writeImage(java.awt.image.RenderedImage, java.io.OutputStream)
- */
- public void writeImage(RenderedImage image, OutputStream out) throws IOException {
- writeImage(image, out, null);
- }
-
- /**
- * @see ImageWriter#writeImage(java.awt.image.RenderedImage, java.io.OutputStream, ImageWriterParams)
- */
- public void writeImage(RenderedImage image, OutputStream out,
- ImageWriterParams params)
- throws IOException {
- javax.imageio.ImageWriter iiowriter = getIIOImageWriter();
- iiowriter.addIIOWriteWarningListener(this);
-
- ImageOutputStream imgout = ImageIO.createImageOutputStream(out);
- try {
-
- ImageWriteParam iwParam = getDefaultWriteParam(iiowriter, image, params);
-
- ImageTypeSpecifier type;
- if (iwParam.getDestinationType() != null) {
- type = iwParam.getDestinationType();
- } else {
- type = ImageTypeSpecifier.createFromRenderedImage(image);
- }
-
- //Handle metadata
- IIOMetadata meta = iiowriter.getDefaultImageMetadata(
- type, iwParam);
- //meta might be null for some JAI codecs as they don't support metadata
- if (params != null && meta != null) {
- meta = updateMetadata(meta, params);
- }
-
- //Write image
- iiowriter.setOutput(imgout);
- IIOImage iioimg = new IIOImage(image, null, meta);
- iiowriter.write(null, iioimg, iwParam);
-
- } finally {
- imgout.close();
- iiowriter.dispose();
- }
- }
-
- private javax.imageio.ImageWriter getIIOImageWriter() {
- Iterator iter = ImageIO.getImageWritersByMIMEType(getMIMEType());
- javax.imageio.ImageWriter iiowriter = null;
- if (iter.hasNext()) {
- iiowriter = (javax.imageio.ImageWriter)iter.next();
- }
- if (iiowriter == null) {
- throw new UnsupportedOperationException("No ImageIO codec for writing "
- + getMIMEType() + " is available!");
- }
- return iiowriter;
- }
-
- /**
- * Returns the default write parameters for encoding the image.
- * @param iiowriter The IIO ImageWriter that will be used
- * @param image the image to be encoded
- * @param params the parameters for this writer instance
- * @return the IIO ImageWriteParam instance
- */
- protected ImageWriteParam getDefaultWriteParam(
- javax.imageio.ImageWriter iiowriter, RenderedImage image,
- ImageWriterParams params) {
- ImageWriteParam param = iiowriter.getDefaultWriteParam();
- //System.err.println("Param: " + params);
- if ((params != null) && (params.getCompressionMethod() != null)) {
- param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
- param.setCompressionType(params.getCompressionMethod());
- }
- return param;
- }
-
- /**
- * Updates the metadata information based on the parameters to this writer.
- * @param meta the metadata
- * @param params the parameters
- * @return the updated metadata
- */
- protected IIOMetadata updateMetadata(IIOMetadata meta, ImageWriterParams params) {
- if (meta.isStandardMetadataFormatSupported()) {
- IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(STANDARD_METADATA_FORMAT);
- IIOMetadataNode dim = getChildNode(root, "Dimension");
- IIOMetadataNode child;
- if (params.getResolution() != null) {
- child = getChildNode(dim, "HorizontalPixelSize");
- if (child == null) {
- child = new IIOMetadataNode("HorizontalPixelSize");
- dim.appendChild(child);
- }
- child.setAttribute("value",
- Double.toString(params.getResolution().doubleValue() / 25.4));
- child = getChildNode(dim, "VerticalPixelSize");
- if (child == null) {
- child = new IIOMetadataNode("VerticalPixelSize");
- dim.appendChild(child);
- }
- child.setAttribute("value",
- Double.toString(params.getResolution().doubleValue() / 25.4));
- }
- try {
- meta.mergeTree(STANDARD_METADATA_FORMAT, root);
- } catch (IIOInvalidTreeException e) {
- throw new RuntimeException("Cannot update image metadata: "
- + e.getMessage());
- }
- }
- return meta;
- }
-
- /**
- * Returns a specific metadata child node
- * @param n the base node
- * @param name the name of the child
- * @return the requested child node
- */
- protected static IIOMetadataNode getChildNode(Node n, String name) {
- NodeList nodes = n.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node child = nodes.item(i);
- if (name.equals(child.getNodeName())) {
- return (IIOMetadataNode)child;
- }
- }
- return null;
- }
-
- /** @see ImageWriter#getMIMEType() */
- public String getMIMEType() {
- return this.targetMIME;
- }
-
- /** @see org.apache.xmlgraphics.image.writer.ImageWriter#isFunctional() */
- public boolean isFunctional() {
- Iterator iter = ImageIO.getImageWritersByMIMEType(getMIMEType());
- //Only return true if an IIO ImageWriter is available in the current environment
- return (iter.hasNext());
- }
-
- /**
- * @see javax.imageio.event.IIOWriteWarningListener#warningOccurred(
- * javax.imageio.ImageWriter, int, java.lang.String)
- */
- public void warningOccurred(javax.imageio.ImageWriter source,
- int imageIndex, String warning) {
- System.err.println("Problem while writing image using ImageI/O: "
- + warning);
- }
-
- /**
- * @see org.apache.xmlgraphics.image.writer.ImageWriter#createMultiImageWriter(
- * java.io.OutputStream)
- */
- public MultiImageWriter createMultiImageWriter(OutputStream out) throws IOException {
- return new IIOMultiImageWriter(out);
- }
-
- /** @see org.apache.xmlgraphics.image.writer.ImageWriter#supportsMultiImageWriter() */
- public boolean supportsMultiImageWriter() {
- javax.imageio.ImageWriter iiowriter = getIIOImageWriter();
- try {
- return iiowriter.canWriteSequence();
- } finally {
- iiowriter.dispose();
- }
- }
-
- private class IIOMultiImageWriter implements MultiImageWriter {
-
- private javax.imageio.ImageWriter iiowriter;
- private ImageOutputStream imageStream;
-
- public IIOMultiImageWriter(OutputStream out) throws IOException {
- this.iiowriter = getIIOImageWriter();
- if (!iiowriter.canWriteSequence()) {
- throw new UnsupportedOperationException("This ImageWriter does not support writing"
- + " multiple images to a single image file.");
- }
- iiowriter.addIIOWriteWarningListener(ImageIOImageWriter.this);
-
- imageStream = ImageIO.createImageOutputStream(out);
- iiowriter.setOutput(imageStream);
- iiowriter.prepareWriteSequence(null);
- }
-
- public void writeImage(RenderedImage image, ImageWriterParams params) throws IOException {
- if (iiowriter == null) {
- throw new IllegalStateException("MultiImageWriter already closed!");
- }
- ImageWriteParam iwParam = getDefaultWriteParam(iiowriter, image, params);
-
- ImageTypeSpecifier type;
- if (iwParam.getDestinationType() != null) {
- type = iwParam.getDestinationType();
- } else {
- type = ImageTypeSpecifier.createFromRenderedImage(image);
- }
-
- //Handle metadata
- IIOMetadata meta = iiowriter.getDefaultImageMetadata(
- type, iwParam);
- //meta might be null for some JAI codecs as they don't support metadata
- if (params != null && meta != null) {
- meta = updateMetadata(meta, params);
- }
-
- //Write image
- IIOImage iioimg = new IIOImage(image, null, meta);
- iiowriter.writeToSequence(iioimg, iwParam);
- }
-
- public void close() throws IOException {
- imageStream.close();
- imageStream = null;
- iiowriter.dispose();
- iiowriter = null;
- }
-
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.writer.imageio;
+
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Iterator;
+
+import javax.imageio.IIOImage;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriteParam;
+import javax.imageio.event.IIOWriteWarningListener;
+import javax.imageio.metadata.IIOInvalidTreeException;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.metadata.IIOMetadataNode;
+import javax.imageio.stream.ImageOutputStream;
+
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.xmlgraphics.image.writer.ImageWriter;
+import org.apache.xmlgraphics.image.writer.ImageWriterParams;
+import org.apache.xmlgraphics.image.writer.MultiImageWriter;
+
+/**
+ * ImageWriter implementation that uses Image I/O to write images.
+ *
+ * @version $Id$
+ */
+public class ImageIOImageWriter implements ImageWriter, IIOWriteWarningListener {
+
+ private static final String STANDARD_METADATA_FORMAT = "javax_imageio_1.0";
+
+ private String targetMIME;
+
+ /**
+ * Main constructor.
+ * @param mime the MIME type of the image format
+ */
+ public ImageIOImageWriter(String mime) {
+ this.targetMIME = mime;
+ }
+
+ /**
+ * @see ImageWriter#writeImage(java.awt.image.RenderedImage, java.io.OutputStream)
+ */
+ public void writeImage(RenderedImage image, OutputStream out) throws IOException {
+ writeImage(image, out, null);
+ }
+
+ /**
+ * @see ImageWriter#writeImage(java.awt.image.RenderedImage, java.io.OutputStream, ImageWriterParams)
+ */
+ public void writeImage(RenderedImage image, OutputStream out,
+ ImageWriterParams params)
+ throws IOException {
+ javax.imageio.ImageWriter iiowriter = getIIOImageWriter();
+ iiowriter.addIIOWriteWarningListener(this);
+
+ ImageOutputStream imgout = ImageIO.createImageOutputStream(out);
+ try {
+
+ ImageWriteParam iwParam = getDefaultWriteParam(iiowriter, image, params);
+
+ ImageTypeSpecifier type;
+ if (iwParam.getDestinationType() != null) {
+ type = iwParam.getDestinationType();
+ } else {
+ type = ImageTypeSpecifier.createFromRenderedImage(image);
+ }
+
+ //Handle metadata
+ IIOMetadata meta = iiowriter.getDefaultImageMetadata(
+ type, iwParam);
+ //meta might be null for some JAI codecs as they don't support metadata
+ if (params != null && meta != null) {
+ meta = updateMetadata(meta, params);
+ }
+
+ //Write image
+ iiowriter.setOutput(imgout);
+ IIOImage iioimg = new IIOImage(image, null, meta);
+ iiowriter.write(null, iioimg, iwParam);
+
+ } finally {
+ imgout.close();
+ iiowriter.dispose();
+ }
+ }
+
+ private javax.imageio.ImageWriter getIIOImageWriter() {
+ Iterator iter = ImageIO.getImageWritersByMIMEType(getMIMEType());
+ javax.imageio.ImageWriter iiowriter = null;
+ if (iter.hasNext()) {
+ iiowriter = (javax.imageio.ImageWriter)iter.next();
+ }
+ if (iiowriter == null) {
+ throw new UnsupportedOperationException("No ImageIO codec for writing "
+ + getMIMEType() + " is available!");
+ }
+ return iiowriter;
+ }
+
+ /**
+ * Returns the default write parameters for encoding the image.
+ * @param iiowriter The IIO ImageWriter that will be used
+ * @param image the image to be encoded
+ * @param params the parameters for this writer instance
+ * @return the IIO ImageWriteParam instance
+ */
+ protected ImageWriteParam getDefaultWriteParam(
+ javax.imageio.ImageWriter iiowriter, RenderedImage image,
+ ImageWriterParams params) {
+ ImageWriteParam param = iiowriter.getDefaultWriteParam();
+ //System.err.println("Param: " + params);
+ if ((params != null) && (params.getCompressionMethod() != null)) {
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+ param.setCompressionType(params.getCompressionMethod());
+ }
+ return param;
+ }
+
+ /**
+ * Updates the metadata information based on the parameters to this writer.
+ * @param meta the metadata
+ * @param params the parameters
+ * @return the updated metadata
+ */
+ protected IIOMetadata updateMetadata(IIOMetadata meta, ImageWriterParams params) {
+ if (meta.isStandardMetadataFormatSupported()) {
+ IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(STANDARD_METADATA_FORMAT);
+ IIOMetadataNode dim = getChildNode(root, "Dimension");
+ IIOMetadataNode child;
+ if (params.getResolution() != null) {
+ child = getChildNode(dim, "HorizontalPixelSize");
+ if (child == null) {
+ child = new IIOMetadataNode("HorizontalPixelSize");
+ dim.appendChild(child);
+ }
+ child.setAttribute("value",
+ Double.toString(params.getResolution().doubleValue() / 25.4));
+ child = getChildNode(dim, "VerticalPixelSize");
+ if (child == null) {
+ child = new IIOMetadataNode("VerticalPixelSize");
+ dim.appendChild(child);
+ }
+ child.setAttribute("value",
+ Double.toString(params.getResolution().doubleValue() / 25.4));
+ }
+ try {
+ meta.mergeTree(STANDARD_METADATA_FORMAT, root);
+ } catch (IIOInvalidTreeException e) {
+ throw new RuntimeException("Cannot update image metadata: "
+ + e.getMessage());
+ }
+ }
+ return meta;
+ }
+
+ /**
+ * Returns a specific metadata child node
+ * @param n the base node
+ * @param name the name of the child
+ * @return the requested child node
+ */
+ protected static IIOMetadataNode getChildNode(Node n, String name) {
+ NodeList nodes = n.getChildNodes();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node child = nodes.item(i);
+ if (name.equals(child.getNodeName())) {
+ return (IIOMetadataNode)child;
+ }
+ }
+ return null;
+ }
+
+ /** @see ImageWriter#getMIMEType() */
+ public String getMIMEType() {
+ return this.targetMIME;
+ }
+
+ /** @see org.apache.xmlgraphics.image.writer.ImageWriter#isFunctional() */
+ public boolean isFunctional() {
+ Iterator iter = ImageIO.getImageWritersByMIMEType(getMIMEType());
+ //Only return true if an IIO ImageWriter is available in the current environment
+ return (iter.hasNext());
+ }
+
+ /**
+ * @see javax.imageio.event.IIOWriteWarningListener#warningOccurred(
+ * javax.imageio.ImageWriter, int, java.lang.String)
+ */
+ public void warningOccurred(javax.imageio.ImageWriter source,
+ int imageIndex, String warning) {
+ System.err.println("Problem while writing image using ImageI/O: "
+ + warning);
+ }
+
+ /**
+ * @see org.apache.xmlgraphics.image.writer.ImageWriter#createMultiImageWriter(
+ * java.io.OutputStream)
+ */
+ public MultiImageWriter createMultiImageWriter(OutputStream out) throws IOException {
+ return new IIOMultiImageWriter(out);
+ }
+
+ /** @see org.apache.xmlgraphics.image.writer.ImageWriter#supportsMultiImageWriter() */
+ public boolean supportsMultiImageWriter() {
+ javax.imageio.ImageWriter iiowriter = getIIOImageWriter();
+ try {
+ return iiowriter.canWriteSequence();
+ } finally {
+ iiowriter.dispose();
+ }
+ }
+
+ private class IIOMultiImageWriter implements MultiImageWriter {
+
+ private javax.imageio.ImageWriter iiowriter;
+ private ImageOutputStream imageStream;
+
+ public IIOMultiImageWriter(OutputStream out) throws IOException {
+ this.iiowriter = getIIOImageWriter();
+ if (!iiowriter.canWriteSequence()) {
+ throw new UnsupportedOperationException("This ImageWriter does not support writing"
+ + " multiple images to a single image file.");
+ }
+ iiowriter.addIIOWriteWarningListener(ImageIOImageWriter.this);
+
+ imageStream = ImageIO.createImageOutputStream(out);
+ iiowriter.setOutput(imageStream);
+ iiowriter.prepareWriteSequence(null);
+ }
+
+ public void writeImage(RenderedImage image, ImageWriterParams params) throws IOException {
+ if (iiowriter == null) {
+ throw new IllegalStateException("MultiImageWriter already closed!");
+ }
+ ImageWriteParam iwParam = getDefaultWriteParam(iiowriter, image, params);
+
+ ImageTypeSpecifier type;
+ if (iwParam.getDestinationType() != null) {
+ type = iwParam.getDestinationType();
+ } else {
+ type = ImageTypeSpecifier.createFromRenderedImage(image);
+ }
+
+ //Handle metadata
+ IIOMetadata meta = iiowriter.getDefaultImageMetadata(
+ type, iwParam);
+ //meta might be null for some JAI codecs as they don't support metadata
+ if (params != null && meta != null) {
+ meta = updateMetadata(meta, params);
+ }
+
+ //Write image
+ IIOImage iioimg = new IIOImage(image, null, meta);
+ iiowriter.writeToSequence(iioimg, iwParam);
+ }
+
+ public void close() throws IOException {
+ imageStream.close();
+ imageStream = null;
+ iiowriter.dispose();
+ iiowriter = null;
+ }
+
+ }
+
+}
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
('svn:executable' removed)
Modified: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java?view=diff&rev=496561&r1=496560&r2=496561
==============================================================================
--- xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java (original)
+++ xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java Mon Jan 15 17:17:01 2007
@@ -1,163 +1,163 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.xmlgraphics.image.writer.imageio;
-
-import java.awt.image.RenderedImage;
-
-import javax.imageio.ImageWriteParam;
-import javax.imageio.ImageWriter;
-import javax.imageio.metadata.IIOInvalidTreeException;
-import javax.imageio.metadata.IIOMetadata;
-import javax.imageio.metadata.IIOMetadataNode;
-import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
-
-import org.apache.xmlgraphics.image.writer.ImageWriterParams;
-
-
-/**
- * ImageWriter that encodes JPEG images using Image I/O.
- *
- * @version $Id$
- */
-public class ImageIOJPEGImageWriter extends ImageIOImageWriter {
-
- private static final String JPEG_NATIVE_FORMAT = "javax_imageio_jpeg_image_1.0";
-
- /**
- * Main constructor.
- */
- public ImageIOJPEGImageWriter() {
- super("image/jpeg");
- }
-
- /**
- * @see ImageIOImageWriter#updateMetadata(javax.imageio.metadata.IIOMetadata, ImageWriterParams)
- */
- protected IIOMetadata updateMetadata(IIOMetadata meta, ImageWriterParams params) {
- //ImageIODebugUtil.dumpMetadata(meta);
- if (JPEG_NATIVE_FORMAT.equals(meta.getNativeMetadataFormatName())) {
- meta = addAdobeTransform(meta);
-
- IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(JPEG_NATIVE_FORMAT);
- //IIOMetadataNode root = new IIOMetadataNode(jpegmeta);
-
- IIOMetadataNode jv = getChildNode(root, "JPEGvariety");
- if (jv == null) {
- jv = new IIOMetadataNode("JPEGvariety");
- root.appendChild(jv);
- }
- IIOMetadataNode child;
- if (params.getResolution() != null) {
- child = getChildNode(jv, "app0JFIF");
- if (child == null) {
- child = new IIOMetadataNode("app0JFIF");
- jv.appendChild(child);
- }
- //JPEG gets special treatment because there seems to be a bug in
- //the JPEG codec in ImageIO converting the pixel size incorrectly
- //(or not at all) when using standard metadata format.
- child.setAttribute("majorVersion", null);
- child.setAttribute("minorVersion", null);
- child.setAttribute("resUnits", "1"); //dots per inch
- child.setAttribute("Xdensity", params.getResolution().toString());
- child.setAttribute("Ydensity", params.getResolution().toString());
- child.setAttribute("thumbWidth", null);
- child.setAttribute("thumbHeight", null);
-
- }
-
- /*
- IIOMetadataNode ms = getChildNode(root, "markerSequence");
- if (ms == null) {
- ms = new IIOMetadataNode("markerSequence");
- root.appendChild(ms);
- }*/
-
- try {
- meta.setFromTree(JPEG_NATIVE_FORMAT, root);
- //meta.mergeTree(JPEG_NATIVE_FORMAT, root);
- } catch (IIOInvalidTreeException e) {
- throw new RuntimeException("Cannot update image metadata: "
- + e.getMessage(), e);
- }
-
- //ImageIODebugUtil.dumpMetadata(meta);
-
- //meta = super.updateMetadata(meta, params);
- //ImageIODebugUtil.dumpMetadata(meta);
- }
-
- return meta;
- }
-
- private static IIOMetadata addAdobeTransform(IIOMetadata meta) {
- // add the adobe transformation (transform 1 -> to YCbCr)
- IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(JPEG_NATIVE_FORMAT);
-
- IIOMetadataNode markerSequence = getChildNode(root, "markerSequence");
- if (markerSequence == null) {
- throw new RuntimeException("Invalid metadata!");
- }
-
- IIOMetadataNode adobeTransform = getChildNode(markerSequence, "app14Adobe");
- if (adobeTransform == null) {
- adobeTransform = new IIOMetadataNode("app14Adobe");
- adobeTransform.setAttribute("transform" , "1"); // convert RGB to YCbCr
- adobeTransform.setAttribute("version", "101");
- adobeTransform.setAttribute("flags0", "0");
- adobeTransform.setAttribute("flags1", "0");
-
- markerSequence.appendChild(adobeTransform);
- } else {
- adobeTransform.setAttribute("transform" , "1");
- }
-
- try {
- meta.setFromTree(JPEG_NATIVE_FORMAT, root);
- } catch (IIOInvalidTreeException e) {
- throw new RuntimeException("Cannot update image metadata: "
- + e.getMessage(), e);
- }
- return meta;
- }
-
- /**
- * @see ImageIOImageWriter#getDefaultWriteParam(javax.imageio.ImageWriter, java.awt.image.RenderedImage, ImageWriterParams)
- */
- protected ImageWriteParam getDefaultWriteParam(
- ImageWriter iiowriter, RenderedImage image,
- ImageWriterParams params) {
- JPEGImageWriteParam param = new JPEGImageWriteParam(iiowriter.getLocale());
- //ImageTypeSpecifier type = ImageTypeSpecifier.createFromRenderedImage(image);
- /*
- ImageTypeSpecifier type = new ImageTypeSpecifier(
- image.getColorModel(), image.getSampleModel());
- */
- /* didn't work as expected...
- ImageTypeSpecifier type = ImageTypeSpecifier.createFromBufferedImageType(
- BufferedImage.TYPE_INT_RGB);
- param.setDestinationType(type);
- param.setSourceBands(new int[] {0, 1, 2});
- */
- return param;
- }
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.writer.imageio;
+
+import java.awt.image.RenderedImage;
+
+import javax.imageio.ImageWriteParam;
+import javax.imageio.ImageWriter;
+import javax.imageio.metadata.IIOInvalidTreeException;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.metadata.IIOMetadataNode;
+import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
+
+import org.apache.xmlgraphics.image.writer.ImageWriterParams;
+
+
+/**
+ * ImageWriter that encodes JPEG images using Image I/O.
+ *
+ * @version $Id$
+ */
+public class ImageIOJPEGImageWriter extends ImageIOImageWriter {
+
+ private static final String JPEG_NATIVE_FORMAT = "javax_imageio_jpeg_image_1.0";
+
+ /**
+ * Main constructor.
+ */
+ public ImageIOJPEGImageWriter() {
+ super("image/jpeg");
+ }
+
+ /**
+ * @see ImageIOImageWriter#updateMetadata(javax.imageio.metadata.IIOMetadata, ImageWriterParams)
+ */
+ protected IIOMetadata updateMetadata(IIOMetadata meta, ImageWriterParams params) {
+ //ImageIODebugUtil.dumpMetadata(meta);
+ if (JPEG_NATIVE_FORMAT.equals(meta.getNativeMetadataFormatName())) {
+ meta = addAdobeTransform(meta);
+
+ IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(JPEG_NATIVE_FORMAT);
+ //IIOMetadataNode root = new IIOMetadataNode(jpegmeta);
+
+ IIOMetadataNode jv = getChildNode(root, "JPEGvariety");
+ if (jv == null) {
+ jv = new IIOMetadataNode("JPEGvariety");
+ root.appendChild(jv);
+ }
+ IIOMetadataNode child;
+ if (params.getResolution() != null) {
+ child = getChildNode(jv, "app0JFIF");
+ if (child == null) {
+ child = new IIOMetadataNode("app0JFIF");
+ jv.appendChild(child);
+ }
+ //JPEG gets special treatment because there seems to be a bug in
+ //the JPEG codec in ImageIO converting the pixel size incorrectly
+ //(or not at all) when using standard metadata format.
+ child.setAttribute("majorVersion", null);
+ child.setAttribute("minorVersion", null);
+ child.setAttribute("resUnits", "1"); //dots per inch
+ child.setAttribute("Xdensity", params.getResolution().toString());
+ child.setAttribute("Ydensity", params.getResolution().toString());
+ child.setAttribute("thumbWidth", null);
+ child.setAttribute("thumbHeight", null);
+
+ }
+
+ /*
+ IIOMetadataNode ms = getChildNode(root, "markerSequence");
+ if (ms == null) {
+ ms = new IIOMetadataNode("markerSequence");
+ root.appendChild(ms);
+ }*/
+
+ try {
+ meta.setFromTree(JPEG_NATIVE_FORMAT, root);
+ //meta.mergeTree(JPEG_NATIVE_FORMAT, root);
+ } catch (IIOInvalidTreeException e) {
+ throw new RuntimeException("Cannot update image metadata: "
+ + e.getMessage(), e);
+ }
+
+ //ImageIODebugUtil.dumpMetadata(meta);
+
+ //meta = super.updateMetadata(meta, params);
+ //ImageIODebugUtil.dumpMetadata(meta);
+ }
+
+ return meta;
+ }
+
+ private static IIOMetadata addAdobeTransform(IIOMetadata meta) {
+ // add the adobe transformation (transform 1 -> to YCbCr)
+ IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(JPEG_NATIVE_FORMAT);
+
+ IIOMetadataNode markerSequence = getChildNode(root, "markerSequence");
+ if (markerSequence == null) {
+ throw new RuntimeException("Invalid metadata!");
+ }
+
+ IIOMetadataNode adobeTransform = getChildNode(markerSequence, "app14Adobe");
+ if (adobeTransform == null) {
+ adobeTransform = new IIOMetadataNode("app14Adobe");
+ adobeTransform.setAttribute("transform" , "1"); // convert RGB to YCbCr
+ adobeTransform.setAttribute("version", "101");
+ adobeTransform.setAttribute("flags0", "0");
+ adobeTransform.setAttribute("flags1", "0");
+
+ markerSequence.appendChild(adobeTransform);
+ } else {
+ adobeTransform.setAttribute("transform" , "1");
+ }
+
+ try {
+ meta.setFromTree(JPEG_NATIVE_FORMAT, root);
+ } catch (IIOInvalidTreeException e) {
+ throw new RuntimeException("Cannot update image metadata: "
+ + e.getMessage(), e);
+ }
+ return meta;
+ }
+
+ /**
+ * @see ImageIOImageWriter#getDefaultWriteParam(javax.imageio.ImageWriter, java.awt.image.RenderedImage, ImageWriterParams)
+ */
+ protected ImageWriteParam getDefaultWriteParam(
+ ImageWriter iiowriter, RenderedImage image,
+ ImageWriterParams params) {
+ JPEGImageWriteParam param = new JPEGImageWriteParam(iiowriter.getLocale());
+ //ImageTypeSpecifier type = ImageTypeSpecifier.createFromRenderedImage(image);
+ /*
+ ImageTypeSpecifier type = new ImageTypeSpecifier(
+ image.getColorModel(), image.getSampleModel());
+ */
+ /* didn't work as expected...
+ ImageTypeSpecifier type = ImageTypeSpecifier.createFromBufferedImageType(
+ BufferedImage.TYPE_INT_RGB);
+ param.setDestinationType(type);
+ param.setSourceBands(new int[] {0, 1, 2});
+ */
+ return param;
+ }
+
+
+}
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOJPEGImageWriter.java
('svn:executable' removed)
Modified: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOPNGImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOPNGImageWriter.java?view=diff&rev=496561&r1=496560&r2=496561
==============================================================================
--- xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOPNGImageWriter.java (original)
+++ xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOPNGImageWriter.java Mon Jan 15 17:17:01 2007
@@ -1,36 +1,36 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.xmlgraphics.image.writer.imageio;
-
-/**
- * ImageWriter that encodes PNG images using Image I/O.
- *
- * @version $Id$
- */
-public class ImageIOPNGImageWriter extends ImageIOImageWriter {
-
- /**
- * Main constructor.
- */
- public ImageIOPNGImageWriter() {
- super("image/png");
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.writer.imageio;
+
+/**
+ * ImageWriter that encodes PNG images using Image I/O.
+ *
+ * @version $Id$
+ */
+public class ImageIOPNGImageWriter extends ImageIOImageWriter {
+
+ /**
+ * Main constructor.
+ */
+ public ImageIOPNGImageWriter() {
+ super("image/png");
+ }
+
+}
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOPNGImageWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOPNGImageWriter.java
('svn:executable' removed)
Modified: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java?view=diff&rev=496561&r1=496560&r2=496561
==============================================================================
--- xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java (original)
+++ xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java Mon Jan 15 17:17:01 2007
@@ -1,113 +1,113 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.xmlgraphics.image.writer.imageio;
-
-import javax.imageio.metadata.IIOInvalidTreeException;
-import javax.imageio.metadata.IIOMetadata;
-import javax.imageio.metadata.IIOMetadataNode;
-
-import org.apache.xmlgraphics.image.writer.ImageWriterParams;
-
-/**
- * ImageWriter that encodes TIFF images using Image I/O.
- *
- * @version $Id$
- */
-public class ImageIOTIFFImageWriter extends ImageIOImageWriter {
-
- private static final String SUN_TIFF_NATIVE_FORMAT
- = "com_sun_media_imageio_plugins_tiff_image_1.0";
-
- /**
- * Main constructor.
- */
- public ImageIOTIFFImageWriter() {
- super("image/tiff");
- }
-
- /**
- * @see org.apache.xmlgraphics.image.writer.imageio.ImageIOImageWriter#updateMetadata(javax.imageio.metadata.IIOMetadata, org.apache.xmlgraphics.image.writer.ImageWriterParams)
- */
- protected IIOMetadata updateMetadata(IIOMetadata meta, ImageWriterParams params) {
- IIOMetadata ret = super.updateMetadata(meta, params);
-
- //We set the resolution manually using the native format since it appears that
- //it doesn't work properly through the standard metadata. Haven't figured out why
- //that happens.
- if (params.getResolution() != null) {
- if (SUN_TIFF_NATIVE_FORMAT.equals(meta.getNativeMetadataFormatName())) {
-
- //IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(SUN_TIFF_NATIVE_FORMAT);
- IIOMetadataNode root = new IIOMetadataNode(SUN_TIFF_NATIVE_FORMAT);
-
- IIOMetadataNode ifd = getChildNode(root, "TIFFIFD");
- if (ifd == null) {
- ifd = new IIOMetadataNode("TIFFIFD");
- ifd.setAttribute("tagSets",
- "com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet");
- root.appendChild(ifd);
- }
- ifd.appendChild(createResolutionField(282, "XResolution", params));
- ifd.appendChild(createResolutionField(283, "YResolution", params));
-
- //ResolutionUnit
- IIOMetadataNode field, arrayNode, valueNode;
- field = new IIOMetadataNode("TIFFField");
- field.setAttribute("number", Integer.toString(296));
- field.setAttribute("name", "ResolutionUnit");
- arrayNode = new IIOMetadataNode("TIFFShorts");
- field.appendChild(arrayNode);
- valueNode = new IIOMetadataNode("TIFFShort");
- valueNode.setAttribute("value", Integer.toString(3));
- valueNode.setAttribute("description", "Centimeter");
- arrayNode.appendChild(valueNode);
-
- try {
- meta.mergeTree(SUN_TIFF_NATIVE_FORMAT, root);
- } catch (IIOInvalidTreeException e) {
- throw new RuntimeException("Cannot update image metadata: "
- + e.getMessage(), e);
- }
- }
- }
-
- return ret;
- }
-
- private IIOMetadataNode createResolutionField(int number, String name, ImageWriterParams params) {
- IIOMetadataNode field, arrayNode, valueNode;
- field = new IIOMetadataNode("TIFFField");
- field.setAttribute("number", Integer.toString(number));
- field.setAttribute("name", name);
- arrayNode = new IIOMetadataNode("TIFFRationals");
- field.appendChild(arrayNode);
- valueNode = new IIOMetadataNode("TIFFRational");
- arrayNode.appendChild(valueNode);
-
- // Set target resolution
- float pixSzMM = 25.4f / params.getResolution().floatValue();
- // num Pixs in 100 Meters
- int numPix = (int)(((1000 * 100) / pixSzMM) + 0.5);
- int denom = 100 * 100; // Centimeters per 100 Meters;
- valueNode.setAttribute("value", numPix + "/" + denom);
- return field;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.writer.imageio;
+
+import javax.imageio.metadata.IIOInvalidTreeException;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.metadata.IIOMetadataNode;
+
+import org.apache.xmlgraphics.image.writer.ImageWriterParams;
+
+/**
+ * ImageWriter that encodes TIFF images using Image I/O.
+ *
+ * @version $Id$
+ */
+public class ImageIOTIFFImageWriter extends ImageIOImageWriter {
+
+ private static final String SUN_TIFF_NATIVE_FORMAT
+ = "com_sun_media_imageio_plugins_tiff_image_1.0";
+
+ /**
+ * Main constructor.
+ */
+ public ImageIOTIFFImageWriter() {
+ super("image/tiff");
+ }
+
+ /**
+ * @see org.apache.xmlgraphics.image.writer.imageio.ImageIOImageWriter#updateMetadata(javax.imageio.metadata.IIOMetadata, org.apache.xmlgraphics.image.writer.ImageWriterParams)
+ */
+ protected IIOMetadata updateMetadata(IIOMetadata meta, ImageWriterParams params) {
+ IIOMetadata ret = super.updateMetadata(meta, params);
+
+ //We set the resolution manually using the native format since it appears that
+ //it doesn't work properly through the standard metadata. Haven't figured out why
+ //that happens.
+ if (params.getResolution() != null) {
+ if (SUN_TIFF_NATIVE_FORMAT.equals(meta.getNativeMetadataFormatName())) {
+
+ //IIOMetadataNode root = (IIOMetadataNode)meta.getAsTree(SUN_TIFF_NATIVE_FORMAT);
+ IIOMetadataNode root = new IIOMetadataNode(SUN_TIFF_NATIVE_FORMAT);
+
+ IIOMetadataNode ifd = getChildNode(root, "TIFFIFD");
+ if (ifd == null) {
+ ifd = new IIOMetadataNode("TIFFIFD");
+ ifd.setAttribute("tagSets",
+ "com.sun.media.imageio.plugins.tiff.BaselineTIFFTagSet");
+ root.appendChild(ifd);
+ }
+ ifd.appendChild(createResolutionField(282, "XResolution", params));
+ ifd.appendChild(createResolutionField(283, "YResolution", params));
+
+ //ResolutionUnit
+ IIOMetadataNode field, arrayNode, valueNode;
+ field = new IIOMetadataNode("TIFFField");
+ field.setAttribute("number", Integer.toString(296));
+ field.setAttribute("name", "ResolutionUnit");
+ arrayNode = new IIOMetadataNode("TIFFShorts");
+ field.appendChild(arrayNode);
+ valueNode = new IIOMetadataNode("TIFFShort");
+ valueNode.setAttribute("value", Integer.toString(3));
+ valueNode.setAttribute("description", "Centimeter");
+ arrayNode.appendChild(valueNode);
+
+ try {
+ meta.mergeTree(SUN_TIFF_NATIVE_FORMAT, root);
+ } catch (IIOInvalidTreeException e) {
+ throw new RuntimeException("Cannot update image metadata: "
+ + e.getMessage(), e);
+ }
+ }
+ }
+
+ return ret;
+ }
+
+ private IIOMetadataNode createResolutionField(int number, String name, ImageWriterParams params) {
+ IIOMetadataNode field, arrayNode, valueNode;
+ field = new IIOMetadataNode("TIFFField");
+ field.setAttribute("number", Integer.toString(number));
+ field.setAttribute("name", name);
+ arrayNode = new IIOMetadataNode("TIFFRationals");
+ field.appendChild(arrayNode);
+ valueNode = new IIOMetadataNode("TIFFRational");
+ arrayNode.appendChild(valueNode);
+
+ // Set target resolution
+ float pixSzMM = 25.4f / params.getResolution().floatValue();
+ // num Pixs in 100 Meters
+ int numPix = (int)(((1000 * 100) / pixSzMM) + 0.5);
+ int denom = 100 * 100; // Centimeters per 100 Meters;
+ valueNode.setAttribute("value", numPix + "/" + denom);
+ return field;
+ }
+
+}
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOTIFFImageWriter.java
('svn:executable' removed)
Modified: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/util/ImageIODebugUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/util/ImageIODebugUtil.java?view=diff&rev=496561&r1=496560&r2=496561
==============================================================================
--- xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/util/ImageIODebugUtil.java (original)
+++ xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/util/ImageIODebugUtil.java Mon Jan 15 17:17:01 2007
@@ -1,66 +1,66 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.xmlgraphics.util;
-
-import javax.imageio.metadata.IIOMetadata;
-import javax.imageio.metadata.IIOMetadataFormatImpl;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Node;
-
-/**
- * Helper class for debugging stuff in Image I/O.
- *
- * @version $Id$
- */
-public class ImageIODebugUtil {
-
- public static void dumpMetadata(IIOMetadata meta, boolean nativeFormat) {
- String format;
- if (nativeFormat) {
- format = meta.getNativeMetadataFormatName();
- } else {
- format = IIOMetadataFormatImpl.standardMetadataFormatName;
- }
- Node node = meta.getAsTree(format);
- dumpNode(node);
- }
-
- public static void dumpNode(Node node) {
- try {
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer t = tf.newTransformer();
- t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- Source src = new DOMSource(node);
- Result res = new StreamResult(System.out);
- t.transform(src, res);
- System.out.println();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.util;
+
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.metadata.IIOMetadataFormatImpl;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Node;
+
+/**
+ * Helper class for debugging stuff in Image I/O.
+ *
+ * @version $Id$
+ */
+public class ImageIODebugUtil {
+
+ public static void dumpMetadata(IIOMetadata meta, boolean nativeFormat) {
+ String format;
+ if (nativeFormat) {
+ format = meta.getNativeMetadataFormatName();
+ } else {
+ format = IIOMetadataFormatImpl.standardMetadataFormatName;
+ }
+ Node node = meta.getAsTree(format);
+ dumpNode(node);
+ }
+
+ public static void dumpNode(Node node) {
+ try {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer t = tf.newTransformer();
+ t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ Source src = new DOMSource(node);
+ Result res = new StreamResult(System.out);
+ t.transform(src, res);
+ System.out.println();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/util/ImageIODebugUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/util/ImageIODebugUtil.java
('svn:executable' removed)
---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org