001 /*
002 * Copyright 1997-2006 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 java.awt.image;
027
028 import java.awt.geom.Rectangle2D;
029 import java.awt.geom.Point2D;
030 import java.awt.RenderingHints;
031
032 /**
033 * This interface describes single-input/single-output
034 * operations performed on <CODE>BufferedImage</CODE> objects.
035 * It is implemented by <CODE>AffineTransformOp</CODE>,
036 * <CODE>ConvolveOp</CODE>, <CODE>ColorConvertOp</CODE>, <CODE>RescaleOp</CODE>,
037 * and <CODE>LookupOp</CODE>. These objects can be passed into
038 * a <CODE>BufferedImageFilter</CODE> to operate on a
039 * <CODE>BufferedImage</CODE> in the
040 * ImageProducer-ImageFilter-ImageConsumer paradigm.
041 * <p>
042 * Classes that implement this
043 * interface must specify whether or not they allow in-place filtering--
044 * filter operations where the source object is equal to the destination
045 * object.
046 * <p>
047 * This interface cannot be used to describe more sophisticated operations
048 * such as those that take multiple sources. Note that this restriction also
049 * means that the values of the destination pixels prior to the operation are
050 * not used as input to the filter operation.
051
052 * @see BufferedImage
053 * @see BufferedImageFilter
054 * @see AffineTransformOp
055 * @see BandCombineOp
056 * @see ColorConvertOp
057 * @see ConvolveOp
058 * @see LookupOp
059 * @see RescaleOp
060 * @version 10 Feb 1997
061 */
062 public interface BufferedImageOp {
063 /**
064 * Performs a single-input/single-output operation on a
065 * <CODE>BufferedImage</CODE>.
066 * If the color models for the two images do not match, a color
067 * conversion into the destination color model is performed.
068 * If the destination image is null,
069 * a <CODE>BufferedImage</CODE> with an appropriate <CODE>ColorModel</CODE>
070 * is created.
071 * <p>
072 * An <CODE>IllegalArgumentException</CODE> may be thrown if the source
073 * and/or destination image is incompatible with the types of images $
074 * allowed by the class implementing this filter.
075 *
076 * @param src The <CODE>BufferedImage</CODE> to be filtered
077 * @param dest The <CODE>BufferedImage</CODE> in which to store the results$
078 *
079 * @return The filtered <CODE>BufferedImage</CODE>.
080 *
081 * @throws IllegalArgumentException If the source and/or destination
082 * image is not compatible with the types of images allowed by the class
083 * implementing this filter.
084 */
085 public BufferedImage filter(BufferedImage src, BufferedImage dest);
086
087 /**
088 * Returns the bounding box of the filtered destination image.
089 * An <CODE>IllegalArgumentException</CODE> may be thrown if the source
090 * image is incompatible with the types of images allowed
091 * by the class implementing this filter.
092 *
093 * @param src The <CODE>BufferedImage</CODE> to be filtered
094 *
095 * @return The <CODE>Rectangle2D</CODE> representing the destination
096 * image's bounding box.
097 */
098 public Rectangle2D getBounds2D(BufferedImage src);
099
100 /**
101 * Creates a zeroed destination image with the correct size and number of
102 * bands.
103 * An <CODE>IllegalArgumentException</CODE> may be thrown if the source
104 * image is incompatible with the types of images allowed
105 * by the class implementing this filter.
106 *
107 * @param src The <CODE>BufferedImage</CODE> to be filtered
108 * @param destCM <CODE>ColorModel</CODE> of the destination. If null,
109 * the <CODE>ColorModel</CODE> of the source is used.
110 *
111 * @return The zeroed destination image.
112 */
113 public BufferedImage createCompatibleDestImage(BufferedImage src,
114 ColorModel destCM);
115
116 /**
117 * Returns the location of the corresponding destination point given a
118 * point in the source image. If <CODE>dstPt</CODE> is specified, it
119 * is used to hold the return value.
120 * @param srcPt the <code>Point2D</code> that represents the point in
121 * the source image
122 * @param dstPt The <CODE>Point2D</CODE> in which to store the result
123 *
124 * @return The <CODE>Point2D</CODE> in the destination image that
125 * corresponds to the specified point in the source image.
126 */
127 public Point2D getPoint2D(Point2D srcPt, Point2D dstPt);
128
129 /**
130 * Returns the rendering hints for this operation.
131 *
132 * @return The <CODE>RenderingHints</CODE> object for this
133 * <CODE>BufferedImageOp</CODE>. Returns
134 * null if no hints have been set.
135 */
136 public RenderingHints getRenderingHints();
137 }
|