jdk/src/share/classes/java/awt/image/ImageConsumer.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1995-2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt.image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * The interface for objects expressing interest in image data through
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * the ImageProducer interfaces.  When a consumer is added to an image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * producer, the producer delivers all of the data about the image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * using the method calls defined in this interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @see ImageProducer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @author      Jim Graham
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
public interface ImageConsumer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     * The dimensions of the source image are reported using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * setDimensions method call.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * @param width the width of the source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * @param height the height of the source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    void setDimensions(int width, int height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * Sets the extensible list of properties associated with this image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * @param props the list of properties to be associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     *        image
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    void setProperties(Hashtable<?,?> props);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * Sets the ColorModel object used for the majority of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * the pixels reported using the setPixels method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * calls.  Note that each set of pixels delivered using setPixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * contains its own ColorModel object, so no assumption should
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * be made that this model will be the only one used in delivering
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * pixel values.  A notable case where multiple ColorModel objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * may be seen is a filtered image when for each set of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * that it filters, the filter
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * determines  whether the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * pixels can be sent on untouched, using the original ColorModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * or whether the pixels should be modified (filtered) and passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * on using a ColorModel more convenient for the filtering process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @param model the specified <code>ColorModel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @see ColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    void setColorModel(ColorModel model);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * Sets the hints that the ImageConsumer uses to process the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * pixels delivered by the ImageProducer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * The ImageProducer can deliver the pixels in any order, but
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * the ImageConsumer may be able to scale or convert the pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * to the destination ColorModel more efficiently or with higher
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * quality if it knows some information about how the pixels will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * be delivered up front.  The setHints method should be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * before any calls to any of the setPixels methods with a bit mask
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * of hints about the manner in which the pixels will be delivered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * If the ImageProducer does not follow the guidelines for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * indicated hint, the results are undefined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @param hintflags a set of hints that the ImageConsumer uses to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *        process the pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    void setHints(int hintflags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * The pixels will be delivered in a random order.  This tells the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * ImageConsumer not to use any optimizations that depend on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * order of pixel delivery, which should be the default assumption
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * in the absence of any call to the setHints method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @see #setHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    int RANDOMPIXELORDER = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * The pixels will be delivered in top-down, left-to-right order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @see #setHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    int TOPDOWNLEFTRIGHT = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * The pixels will be delivered in (multiples of) complete scanlines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * at a time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @see #setHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    int COMPLETESCANLINES = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * The pixels will be delivered in a single pass.  Each pixel will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * appear in only one call to any of the setPixels methods.  An
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * example of an image format which does not meet this criterion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * is a progressive JPEG image which defines pixels in multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * passes, each more refined than the previous.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @see #setHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    int SINGLEPASS = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * The image contain a single static image.  The pixels will be defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * in calls to the setPixels methods and then the imageComplete method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * will be called with the STATICIMAGEDONE flag after which no more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * image data will be delivered.  An example of an image type which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * would not meet these criteria would be the output of a video feed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * or the representation of a 3D rendering being manipulated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * by the user.  The end of each frame in those types of images will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * be indicated by calling imageComplete with the SINGLEFRAMEDONE flag.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @see #setHints
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @see #imageComplete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    int SINGLEFRAME = 16;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * Delivers the pixels of the image with one or more calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * to this method.  Each call specifies the location and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * size of the rectangle of source pixels that are contained in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * the array of pixels.  The specified ColorModel object should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * be used to convert the pixels into their corresponding color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * and alpha components.  Pixel (m,n) is stored in the pixels array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * at index (n * scansize + m + off).  The pixels delivered using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * this method are all stored as bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @param x the X coordinate of the upper-left corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *        area of pixels to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param y the Y coordinate of the upper-left corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *        area of pixels to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param w the width of the area of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @param h the height of the area of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @param model the specified <code>ColorModel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param pixels the array of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * @param off the offset into the <code>pixels</code> array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @param scansize the distance from one row of pixels to the next in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * the <code>pixels</code> array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @see ColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    void setPixels(int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                   ColorModel model, byte pixels[], int off, int scansize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * The pixels of the image are delivered using one or more calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * to the setPixels method.  Each call specifies the location and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * size of the rectangle of source pixels that are contained in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * the array of pixels.  The specified ColorModel object should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * be used to convert the pixels into their corresponding color
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * and alpha components.  Pixel (m,n) is stored in the pixels array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * at index (n * scansize + m + off).  The pixels delivered using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * this method are all stored as ints.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * this method are all stored as ints.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @param x the X coordinate of the upper-left corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *        area of pixels to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @param y the Y coordinate of the upper-left corner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *        area of pixels to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @param w the width of the area of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @param h the height of the area of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @param model the specified <code>ColorModel</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @param pixels the array of pixels
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @param off the offset into the <code>pixels</code> array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @param scansize the distance from one row of pixels to the next in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * the <code>pixels</code> array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * @see ColorModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    void setPixels(int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                   ColorModel model, int pixels[], int off, int scansize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * The imageComplete method is called when the ImageProducer is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * finished delivering all of the pixels that the source image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * contains, or when a single frame of a multi-frame animation has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * been completed, or when an error in loading or producing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * image has occured.  The ImageConsumer should remove itself from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * list of consumers registered with the ImageProducer at this time,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * unless it is interested in successive frames.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @param status the status of image loading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @see ImageProducer#removeConsumer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    void imageComplete(int status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * An error was encountered while producing the image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * @see #imageComplete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    int IMAGEERROR = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * One frame of the image is complete but there are more frames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * to be delivered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @see #imageComplete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    int SINGLEFRAMEDONE = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * The image is complete and there are no more pixels or frames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * to be delivered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @see #imageComplete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    int STATICIMAGEDONE = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * The image creation process was deliberately aborted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @see #imageComplete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    int IMAGEABORTED = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
}