home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / java.z / ImageConsumer.java < prev    next >
Text File  |  1996-05-03  |  7KB  |  189 lines

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