1. /*
  2. * @(#)RenderedImage.java 1.20 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. /* ****************************************************************
  8. ******************************************************************
  9. ******************************************************************
  10. *** COPYRIGHT (c) Eastman Kodak Company, 1997
  11. *** As an unpublished work pursuant to Title 17 of the United
  12. *** States Code. All rights reserved.
  13. ******************************************************************
  14. ******************************************************************
  15. ******************************************************************/
  16. package java.awt.image;
  17. import java.awt.Rectangle;
  18. import java.util.Dictionary;
  19. import java.util.Vector;
  20. /**
  21. * RenderedImage is a common interface for objects which contain
  22. * or can produce image data in the form of Rasters. The image
  23. * data may be stored/produced as a single tile or a regular array
  24. * of tiles.
  25. */
  26. public interface RenderedImage {
  27. /**
  28. * Returns a vector of RenderedImages that are the immediate sources of
  29. * image data for this RenderedImage. This method returns null if
  30. * the RenderedImage object has no information about its immediate
  31. * sources. It returns an empty Vector if the RenderedImage object has
  32. * no immediate sources.
  33. * @return a Vector of <code>RenderedImage</code> objects.
  34. */
  35. Vector getSources();
  36. /**
  37. * Gets a property from the property set of this image. The set of
  38. * properties and whether it is immutable is determined by the
  39. * implementing class. This method returns
  40. * java.awt.Image.UndefinedProperty if the specified property is
  41. * not defined for this RenderedImage.
  42. * @param name the name of the property
  43. * @return the property indicated by the specified name.
  44. * @see java.awt.Image#UndefinedProperty
  45. */
  46. Object getProperty(String name);
  47. /**
  48. * Returns an array of names recognized by
  49. * {@link #getProperty(String) getProperty(String)}
  50. * or <code>null</code>, if no property names are recognized.
  51. * @return a <code>String</code> array containing all of the
  52. * property names that <code>getProperty(String)</code> recognizes;
  53. * or <code>null</code> if no property names are recognized.
  54. */
  55. String[] getPropertyNames();
  56. /**
  57. * Returns the ColorModel associated with this image. All Rasters
  58. * returned from this image will have this as their ColorModel. This
  59. * can return null.
  60. * @return the <code>ColorModel</code> of this image.
  61. */
  62. ColorModel getColorModel();
  63. /**
  64. * Returns the SampleModel associated with this image. All Rasters
  65. * returned from this image will have this as their SampleModel.
  66. * @return the <code>SampleModel</code> of this image.
  67. */
  68. SampleModel getSampleModel();
  69. /**
  70. * Returns the width of the RenderedImage.
  71. * @return the width of this <code>RenderedImage</code>.
  72. */
  73. int getWidth();
  74. /**
  75. * Returns the height of the RenderedImage.
  76. * @return the height of this <code>RenderedImage</code>.
  77. */
  78. int getHeight();
  79. /**
  80. * Returns the minimum X coordinate (inclusive) of the RenderedImage.
  81. * @return the X coordinate of this <code>RenderedImage</code>.
  82. */
  83. int getMinX();
  84. /**
  85. * Returns the minimum Y coordinate (inclusive) of the RenderedImage.
  86. * @return the Y coordinate of this <code>RenderedImage</code>.
  87. */
  88. int getMinY();
  89. /**
  90. * Returns the number of tiles in the X direction.
  91. * @return the number of tiles in the X direction.
  92. */
  93. int getNumXTiles();
  94. /**
  95. * Returns the number of tiles in the Y direction.
  96. * @return the number of tiles in the Y direction.
  97. */
  98. int getNumYTiles();
  99. /**
  100. * Returns the minimum tile index in the X direction.
  101. * @return the minimum tile index in the X direction.
  102. */
  103. int getMinTileX();
  104. /**
  105. * Returns the minimum tile index in the Y direction.
  106. * @return the minimum tile index in the X direction.
  107. */
  108. int getMinTileY();
  109. /**
  110. * Returns the tile width in pixels. All tiles must have the same
  111. * width.
  112. * @return the tile width in pixels.
  113. */
  114. int getTileWidth();
  115. /**
  116. * Returns the tile height in pixels. All tiles must have the same
  117. * height.
  118. * @return the tile height in pixels.
  119. */
  120. int getTileHeight();
  121. /**
  122. * Returns the X offset of the tile grid relative to the origin,
  123. * i.e., the X coordinate of the upper-left pixel of tile (0, 0).
  124. * (Note that tile (0, 0) may not actually exist.)
  125. * @return the X offset of the tile grid relative to the origin.
  126. */
  127. int getTileGridXOffset();
  128. /**
  129. * Returns the Y offset of the tile grid relative to the origin,
  130. * i.e., the Y coordinate of the upper-left pixel of tile (0, 0).
  131. * (Note that tile (0, 0) may not actually exist.)
  132. * @return the Y offset of the tile grid relative to the origin.
  133. */
  134. int getTileGridYOffset();
  135. /**
  136. * Returns tile (tileX, tileY). Note that tileX and tileY are indices
  137. * into the tile array, not pixel locations. The Raster that is returned
  138. * is live and will be updated if the image is changed.
  139. * @param tileX the X index of the requested tile in the tile array
  140. * @param tileY the Y index of the requested tile in the tile array
  141. * @return the tile given the specified indices.
  142. */
  143. Raster getTile(int tileX, int tileY);
  144. /**
  145. * Returns the image as one large tile (for tile based
  146. * images this will require fetching the whole image
  147. * and copying the image data over). The Raster returned is
  148. * a copy of the image data and will not be updated if the image
  149. * is changed.
  150. * @return the image as one large tile.
  151. */
  152. Raster getData();
  153. /**
  154. * Computes and returns an arbitrary region of the RenderedImage.
  155. * The Raster returned is a copy of the image data and will not
  156. * be updated if the image is changed.
  157. * @param rect the region of the RenderedImage to be returned.
  158. * @return the region of the <code>RenderedImage</code>
  159. * indicated by the specified <code>Rectangle</code>.
  160. */
  161. Raster getData(Rectangle rect);
  162. /**
  163. * Computes an arbitrary rectangular region of the RenderedImage
  164. * and copies it into a caller-supplied WritableRaster. The region
  165. * to be computed is determined from the bounds of the supplied
  166. * WritableRaster. The supplied WritableRaster must have a
  167. * SampleModel that is compatible with this image. If raster is null,
  168. * an appropriate WritableRaster is created.
  169. * @param raster a WritableRaster to hold the returned portion of the
  170. * image, or null.
  171. * @return a reference to the supplied or created WritableRaster.
  172. */
  173. WritableRaster copyData(WritableRaster raster);
  174. }