001 /* ImageConsumer.java -- Java interface for image consumption
002 Copyright (C) 1999, 2003 Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038
039 package java.awt.image;
040
041 import java.util.Hashtable;
042
043 /**
044 * An object implementing the <code>ImageProducer</code> interface can
045 * use objects implementing this interface to deliver the image data.
046 *
047 * @author C. Brian Jones (cbj@gnu.org)
048 */
049 public interface ImageConsumer
050 {
051 /**
052 * The pixel order may be random. This should be
053 * the default assumption of the <code>ImageConsumer</code>.
054 *
055 * @see #setHints
056 */
057 int RANDOMPIXELORDER = 1;
058
059 /**
060 * The pixel order is top-down, left-right.
061 *
062 * @see #setHints
063 */
064 int TOPDOWNLEFTRIGHT = 2;
065
066 /**
067 * The pixel order is in multiples of complete scanlines.
068 *
069 * @see #setHints
070 */
071 int COMPLETESCANLINES = 4;
072
073 /**
074 * The pixels will be delivered in a single pass. There is at
075 * most one call to <code>setPixels</code> for any single pixel.
076 *
077 * @see #setHints
078 * @see #setPixels(int, int, int, int, ColorModel, int[], int, int)
079 */
080 int SINGLEPASS = 8;
081
082 /**
083 * The pixels will be delivered with multiple calls to
084 * <code>setPixels</code>. The image contains a single frame
085 * which ends when <code>imageComplete</code> is called with the
086 * <code>STATICIMAGEDONE</code> flag. If the image is constantly
087 * changing such as with video then the end of each frame is
088 * marked by a similar call to <code>imageComplete</code> with the
089 * <code>SINGLEFRAMEDONE</code> flag.
090 *
091 * @see #setHints
092 * @see #imageComplete
093 */
094 int SINGLEFRAME = 16;
095
096 /**
097 * Indicates an error occurred while producing an image.
098 *
099 * @see #imageComplete
100 */
101 int IMAGEERROR = 1;
102
103 /**
104 * A single frame is complete but more will follow.
105 *
106 * @see #imageComplete
107 */
108 int SINGLEFRAMEDONE = 2;
109
110 /**
111 * The image is complete and no more pixels or frames will follow.
112 *
113 * @see #imageComplete
114 */
115 int STATICIMAGEDONE = 3;
116
117 /**
118 * Production of the image has been aborted.
119 *
120 * @see #imageComplete
121 */
122 int IMAGEABORTED = 4;
123
124 /**
125 * An <code>ImageProducer</code> indicates the size of the image
126 * being produced using this method.
127 *
128 * @param width the width of the image
129 * @param height the height of the image
130 */
131 void setDimensions(int width, int height);
132
133 /**
134 * An <code>ImageProducer</code> can set a list of properties
135 * associated with this image by using this method.
136 *
137 * @param props the list of properties associated with this image
138 */
139 void setProperties(Hashtable<?,?> props);
140
141 /**
142 * This <code>ColorModel</code> should indicate the model used by
143 * the majority of calls to <code>setPixels</code>. Each call to
144 * <code>setPixels</code> could however indicate a different
145 * <code>ColorModel</code>.
146 *
147 * @param model the color model to be used most often by setPixels
148 * @see ColorModel
149 */
150 void setColorModel(ColorModel model);
151
152 /**
153 * The <code>ImageProducer</code> should call this method with a
154 * bit mask of hints from any of <code>RANDOMPIXELORDER</code>,
155 * <code>TOPDOWNLEFTRIGHT</code>, <code>COMPLETESCANLINES</code>,
156 * <code>SINGLEPASS</code>, <code>SINGLEFRAME</code>.
157 *
158 * @param flags a bit mask of hints
159 */
160 void setHints(int flags);
161
162 /**
163 * Deliver a subset of an ImageProducer's pixels to this ImageConsumer.
164 *
165 * Each element of the pixels array represents one pixel. The
166 * pixel data is formatted according to the color model model.
167 * The x and y parameters are the coordinates of the block of
168 * pixels being delivered to this ImageConsumer. They are
169 * specified relative to the top left corner of the image being
170 * produced. Likewise, w and h are the pixel block's dimensions.
171 *
172 * @param x x coordinate of pixel block
173 * @param y y coordinate of pixel block
174 * @param w width of pixel block
175 * @param h height of pixel block
176 * @param model color model used to interpret pixel data
177 * @param pixels pixel block data
178 * @param offset offset into pixels array
179 * @param scansize width of one row in the pixel block
180 */
181 void setPixels(int x, int y, int w, int h,
182 ColorModel model, byte[] pixels, int offset, int scansize);
183
184 /**
185 * Deliver a subset of an ImageProducer's pixels to this ImageConsumer.
186 *
187 * Each element of the pixels array represents one pixel. The
188 * pixel data is formatted according to the color model model.
189 * The x and y parameters are the coordinates of the rectangular
190 * region of pixels being delivered to this ImageConsumer,
191 * specified relative to the top left corner of the image being
192 * produced. Likewise, w and h are the pixel region's dimensions.
193 *
194 * @param x x coordinate of pixel block
195 * @param y y coordinate of pixel block
196 * @param w width of pixel block
197 * @param h height of pixel block
198 * @param model color model used to interpret pixel data
199 * @param pixels pixel block data
200 * @param offset offset into pixels array
201 * @param scansize width of one row in the pixel block
202 */
203 void setPixels(int x, int y, int w, int h,
204 ColorModel model, int[] pixels, int offset, int scansize);
205
206 /**
207 * The <code>ImageProducer</code> calls this method to indicate a
208 * single frame or the entire image is complete. The method is
209 * also used to indicate an error in loading or producing the
210 * image.
211 *
212 * @param status the status of image production, represented by a
213 * bitwise OR of ImageConsumer flags
214 */
215 void imageComplete(int status);
216 }