1. /*
  2. * @(#)RenderedImage.java 1.16 01/11/29
  3. *
  4. * Copyright 2002 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. */
  34. Vector getSources();
  35. /**
  36. * Gets a property from the property set of this image. The set of
  37. * properties and whether it is immutable is determined by the
  38. * implementing class. This method returns
  39. * java.awt.Image.UndefinedProperty if the specified property is
  40. * not defined for this RenderedImage.
  41. * @see java.awt.Image#UndefinedProperty
  42. */
  43. Object getProperty(String name);
  44. /**
  45. * Returns an array of names recognized by
  46. * {@link #getProperty(String) getProperty(String)}
  47. * or <code>null</code>, if no property names are recognized.
  48. * @return a <code>String</code> array containing all of the
  49. * property names that <code>getProperty(String)</code> recognizes;
  50. * or <code>null</code> if no property names are recognized.
  51. */
  52. String[] getPropertyNames();
  53. /**
  54. * Returns the ColorModel associated with this image. All Rasters returned
  55. * from this image will have this as their ColorModel. This can return
  56. * null.
  57. */
  58. ColorModel getColorModel();
  59. /**
  60. * Returns the SampleModel associated with this image. All Rasters returned
  61. * from this image will have this as their SampleModel.
  62. */
  63. SampleModel getSampleModel();
  64. /**
  65. * Returns the width of the RenderedImage.
  66. */
  67. int getWidth();
  68. /**
  69. * Returns the height of the RenderedImage.
  70. */
  71. int getHeight();
  72. /**
  73. * Returns the minimum X coordinate (inclusive) of the RenderedImage.
  74. */
  75. int getMinX();
  76. /**
  77. * Returns the minimum Y coordinate (inclusive) of the RenderedImage.
  78. */
  79. int getMinY();
  80. /**
  81. * Returns the number of tiles in the X direction.
  82. */
  83. int getNumXTiles();
  84. /**
  85. * Returns the number of tiles in the Y direction.
  86. */
  87. int getNumYTiles();
  88. /** Returns the minimum tile index in the X direction. */
  89. int getMinTileX();
  90. /** Returns the minimum tile index in the Y direction. */
  91. int getMinTileY();
  92. /** Returns the tile width in pixels. All tiles must have the same width.
  93. */
  94. int getTileWidth();
  95. /** Returns the tile height in pixels. All tiles must have the same height.
  96. */
  97. int getTileHeight();
  98. /**
  99. * Returns the X offset of the tile grid relative to the origin,
  100. * i.e., the X coordinate of the upper-left pixel of tile (0, 0).
  101. * (Note that tile (0, 0) may not actually exist.)
  102. */
  103. int getTileGridXOffset();
  104. /**
  105. * Returns the Y offset of the tile grid relative to the origin,
  106. * i.e., the Y coordinate of the upper-left pixel of tile (0, 0).
  107. * (Note that tile (0, 0) may not actually exist.)
  108. */
  109. int getTileGridYOffset();
  110. /**
  111. * Returns tile (tileX, tileY). Note that tileX and tileY are indices
  112. * into the tile array, not pixel locations. The Raster that is returned
  113. * is live and will be updated if the image is changed.
  114. * @param tileX the X index of the requested tile in the tile array.
  115. * @param tileY the Y index of the requested tile in the tile array.
  116. */
  117. Raster getTile(int tileX, int tileY);
  118. /**
  119. * Returns the image as one large tile (for tile based
  120. * images this will require fetching the whole image
  121. * and copying the image data over). The Raster returned is
  122. * a copy of the image data and will not be updated if the image
  123. * is changed.
  124. */
  125. Raster getData();
  126. /**
  127. * Computes and returns an arbitrary region of the RenderedImage.
  128. * The Raster returned is a copy of the image data and will not
  129. * be updated if the image is changed.
  130. * @param rect the region of the RenderedImage to be returned.
  131. */
  132. Raster getData(Rectangle rect);
  133. /**
  134. * Computes an arbitrary rectangular region of the RenderedImage
  135. * and copies it into a caller-supplied WritableRaster. The region
  136. * to be computed is determined from the bounds of the supplied
  137. * WritableRaster. The supplied WritableRaster must have a
  138. * SampleModel that is compatible with this image. If raster is null,
  139. * an appropriate WritableRaster is created.
  140. * @param raster a WritableRaster to hold the returned portion of the
  141. * image, or null.
  142. * @return a reference to the supplied or created WritableRaster.
  143. */
  144. WritableRaster copyData(WritableRaster raster);
  145. }