001 /*
002 * Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.imageio;
027
028 import javax.imageio.metadata.IIOMetadata;
029
030 /**
031 * An interface providing metadata transcoding capability.
032 *
033 * <p> Any image may be transcoded (written to a different format
034 * than the one it was originally stored in) simply by performing
035 * a read operation followed by a write operation. However, loss
036 * of data may occur in this process due to format differences.
037 *
038 * <p> In general, the best results will be achieved when
039 * format-specific metadata objects can be created to encapsulate as
040 * much information about the image and its associated metadata as
041 * possible, in terms that are understood by the specific
042 * <code>ImageWriter</code> used to perform the encoding.
043 *
044 * <p> An <code>ImageTranscoder</code> may be used to convert the
045 * <code>IIOMetadata</code> objects supplied by the
046 * <code>ImageReader</code> (representing per-stream and per-image
047 * metadata) into corresponding objects suitable for encoding by a
048 * particular <code>ImageWriter</code>. In the case where the methods
049 * of this interface are being called directly on an
050 * <code>ImageWriter</code>, the output will be suitable for that
051 * writer.
052 *
053 * <p> The internal details of converting an <code>IIOMetadata</code>
054 * object into a writer-specific format will vary according to the
055 * context of the operation. Typically, an <code>ImageWriter</code>
056 * will inspect the incoming object to see if it implements additional
057 * interfaces with which the writer is familiar. This might be the
058 * case, for example, if the object was obtained by means of a read
059 * operation on a reader plug-in written by the same vendor as the
060 * writer. In this case, the writer may access the incoming object by
061 * means of its plug-in specific interfaces. In this case, the
062 * re-encoding may be close to lossless if the image file format is
063 * kept constant. If the format is changing, the writer may still
064 * attempt to preserve as much information as possible.
065 *
066 * <p> If the incoming object does not implement any additional
067 * interfaces known to the writer, the writer has no choice but to
068 * access it via the standard <code>IIOMetadata</code> interfaces such
069 * as the tree view provided by <code>IIOMetadata.getAsTree</code>.
070 * In this case, there is likely to be significant loss of
071 * information.
072 *
073 * <p> An independent <code>ImageTranscoder</code> essentially takes
074 * on the same role as the writer plug-in in the above examples. It
075 * must be familiar with the private interfaces used by both the
076 * reader and writer plug-ins, and manually instantiate an object that
077 * will be usable by the writer. The resulting metadata objects may
078 * be used by the writer directly.
079 *
080 * <p> No independent implementations of <code>ImageTranscoder</code>
081 * are provided as part of the standard API. Instead, the intention
082 * of this interface is to provide a way for implementations to be
083 * created and discovered by applications as the need arises.
084 *
085 * @version 0.5
086 */
087 public interface ImageTranscoder {
088
089 /**
090 * Returns an <code>IIOMetadata</code> object that may be used for
091 * encoding and optionally modified using its document interfaces
092 * or other interfaces specific to the writer plug-in that will be
093 * used for encoding.
094 *
095 * <p> An optional <code>ImageWriteParam</code> may be supplied
096 * for cases where it may affect the structure of the stream
097 * metadata.
098 *
099 * <p> If the supplied <code>ImageWriteParam</code> contains
100 * optional setting values not understood by this writer or
101 * transcoder, they will be ignored.
102 *
103 * @param inData an <code>IIOMetadata</code> object representing
104 * stream metadata, used to initialize the state of the returned
105 * object.
106 * @param param an <code>ImageWriteParam</code> that will be used to
107 * encode the image, or <code>null</code>.
108 *
109 * @return an <code>IIOMetadata</code> object, or
110 * <code>null</code> if the plug-in does not provide metadata
111 * encoding capabilities.
112 *
113 * @exception IllegalArgumentException if <code>inData</code> is
114 * <code>null</code>.
115 */
116 IIOMetadata convertStreamMetadata(IIOMetadata inData,
117 ImageWriteParam param);
118
119 /**
120 * Returns an <code>IIOMetadata</code> object that may be used for
121 * encoding and optionally modified using its document interfaces
122 * or other interfaces specific to the writer plug-in that will be
123 * used for encoding.
124 *
125 * <p> An optional <code>ImageWriteParam</code> may be supplied
126 * for cases where it may affect the structure of the image
127 * metadata.
128 *
129 * <p> If the supplied <code>ImageWriteParam</code> contains
130 * optional setting values not understood by this writer or
131 * transcoder, they will be ignored.
132 *
133 * @param inData an <code>IIOMetadata</code> object representing
134 * image metadata, used to initialize the state of the returned
135 * object.
136 * @param imageType an <code>ImageTypeSpecifier</code> indicating
137 * the layout and color information of the image with which the
138 * metadata will be associated.
139 * @param param an <code>ImageWriteParam</code> that will be used to
140 * encode the image, or <code>null</code>.
141 *
142 * @return an <code>IIOMetadata</code> object,
143 * or <code>null</code> if the plug-in does not provide
144 * metadata encoding capabilities.
145 *
146 * @exception IllegalArgumentException if either of
147 * <code>inData</code> or <code>imageType</code> is
148 * <code>null</code>.
149 */
150 IIOMetadata convertImageMetadata(IIOMetadata inData,
151 ImageTypeSpecifier imageType, ImageWriteParam param);
152 }
|