home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / ImageConsumer.java < prev    next >
Text File  |  1997-05-20  |  7KB  |  192 lines

  1. /*
  2.  * @(#)ImageConsumer.java    1.12 96/11/23
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.awt.image;
  24.  
  25. import java.util.Hashtable;
  26.  
  27. /**
  28.  * The interface for objects expressing interest in image data through
  29.  * the ImageProducer interfaces.  When a consumer is added to an image
  30.  * producer, the producer delivers all of the data about the image
  31.  * using the method calls defined in this interface.
  32.  *
  33.  * @see ImageProducer
  34.  *
  35.  * @version    1.12 11/23/96
  36.  * @author     Jim Graham
  37.  */
  38. public interface ImageConsumer {
  39.     /**
  40.      * The dimensions of the source image are reported using the
  41.      * setDimensions method call.
  42.      */
  43.     void setDimensions(int width, int height);
  44.  
  45.     /**
  46.      * Sets the extensible list of properties associated with this image.
  47.      */
  48.     void setProperties(Hashtable props);
  49.  
  50.     /**
  51.      * The ColorModel object used for the majority of
  52.      * the pixels reported using the setPixels method
  53.      * calls.  Note that each set of pixels delivered using setPixels
  54.      * contains its own ColorModel object, so no assumption should
  55.      * be made that this model will be the only one used in delivering
  56.      * pixel values.  A notable case where multiple ColorModel objects
  57.      * may be seen is a filtered image when for each set of pixels
  58.      * that it filters, the filter
  59.      * determines  whether the
  60.      * pixels can be sent on untouched, using the original ColorModel,
  61.      * or whether the pixels should be modified (filtered) and passed
  62.      * on using a ColorModel more convenient for the filtering process.
  63.      * @see ColorModel
  64.      */
  65.     void setColorModel(ColorModel model);
  66.  
  67.     /**
  68.      * The ImageProducer can deliver the pixels in any order, but
  69.      * the ImageConsumer may be able to scale or convert the pixels
  70.      * to the destination ColorModel more efficiently or with higher
  71.      * quality if it knows some information about how the pixels will
  72.      * be delivered up front.  The setHints method should be called
  73.      * before any calls to any of the setPixels methods with a bit mask
  74.      * of hints about the manner in which the pixels will be delivered.
  75.      * If the ImageProducer does not follow the guidelines for the
  76.      * indicated hint, the results are undefined.
  77.      */
  78.     void setHints(int hintflags);
  79.  
  80.     /**
  81.      * The pixels will be delivered in a random order.  This tells the
  82.      * ImageConsumer not to use any optimizations that depend on the
  83.      * order of pixel delivery, which should be the default assumption
  84.      * in the absence of any call to the setHints method.
  85.      * @see #setHints
  86.      */
  87.     int RANDOMPIXELORDER = 1;
  88.  
  89.     /**
  90.      * The pixels will be delivered in top-down, left-to-right order.
  91.      * @see #setHints
  92.      */
  93.     int TOPDOWNLEFTRIGHT = 2;
  94.  
  95.     /**
  96.      * The pixels will be delivered in (multiples of) complete scanlines
  97.      * at a time.
  98.      * @see #setHints
  99.      */
  100.     int COMPLETESCANLINES = 4;
  101.  
  102.     /**
  103.      * The pixels will be delivered in a single pass.  Each pixel will
  104.      * appear in only one call to any of the setPixels methods.  An
  105.      * example of an image format which does not meet this criterion
  106.      * is a progressive JPEG image which defines pixels in multiple
  107.      * passes, each more refined than the previous.
  108.      * @see #setHints
  109.      */
  110.     int SINGLEPASS = 8;
  111.  
  112.     /**
  113.      * The image contain a single static image.  The pixels will be defined
  114.      * in calls to the setPixels methods and then the imageComplete method
  115.      * will be called with the STATICIMAGEDONE flag after which no more
  116.      * image data will be delivered.  An example of an image type which
  117.      * would not meet these criteria would be the output of a video feed,
  118.      * or the representation of a 3D rendering being manipulated
  119.      * by the user.  The end of each frame in those types of images will
  120.      * be indicated by calling imageComplete with the SINGLEFRAMEDONE flag.
  121.      * @see #setHints
  122.      * @see #imageComplete
  123.      */
  124.     int SINGLEFRAME = 16;
  125.  
  126.     /**
  127.      * The pixels of the image are delivered using one or more calls
  128.      * to the setPixels method.  Each call specifies the location and
  129.      * size of the rectangle of source pixels that are contained in
  130.      * the array of pixels.  The specified ColorModel object should
  131.      * be used to convert the pixels into their corresponding color
  132.      * and alpha components.  Pixel (m,n) is stored in the pixels array
  133.      * at index (n * scansize + m + off).  The pixels delivered using
  134.      * this method are all stored as bytes.
  135.      * @see ColorModel
  136.      */
  137.     void setPixels(int x, int y, int w, int h,
  138.            ColorModel model, byte pixels[], int off, int scansize);
  139.  
  140.     /**
  141.      * The pixels of the image are delivered using one or more calls
  142.      * to the setPixels method.  Each call specifies the location and
  143.      * size of the rectangle of source pixels that are contained in
  144.      * the array of pixels.  The specified ColorModel object should
  145.      * be used to convert the pixels into their corresponding color
  146.      * and alpha components.  Pixel (m,n) is stored in the pixels array
  147.      * at index (n * scansize + m + off).  The pixels delivered using
  148.      * this method are all stored as ints.
  149.      * @see ColorModel
  150.      */
  151.     void setPixels(int x, int y, int w, int h,
  152.            ColorModel model, int pixels[], int off, int scansize);
  153.  
  154.     /**
  155.      * The imageComplete method is called when the ImageProducer is
  156.      * finished delivering all of the pixels that the source image
  157.      * contains, or when a single frame of a multi-frame animation has
  158.      * been completed, or when an error in loading or producing the
  159.      * image has occured.  The ImageConsumer should remove itself from the
  160.      * list of consumers registered with the ImageProducer at this time,
  161.      * unless it is interested in successive frames.
  162.      * @see ImageProducer#removeConsumer
  163.      */
  164.     void imageComplete(int status);
  165.  
  166.     /**
  167.      * An error was encountered while producing the image.
  168.      * @see #imageComplete
  169.      */
  170.     int IMAGEERROR = 1;
  171.  
  172.     /**
  173.      * One frame of the image is complete but there are more frames
  174.      * to be delivered.
  175.      * @see #imageComplete
  176.      */
  177.     int SINGLEFRAMEDONE = 2;
  178.  
  179.     /**
  180.      * The image is complete and there are no more pixels or frames
  181.      * to be delivered.
  182.      * @see #imageComplete
  183.      */
  184.     int STATICIMAGEDONE = 3;
  185.  
  186.     /**
  187.      * The image creation process was deliberately aborted.
  188.      * @see #imageComplete
  189.      */
  190.     int IMAGEABORTED = 4;
  191. }
  192.