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