All Downloads are FREE. Search and download functionalities are using the official Maven repository.

java.awt.image.BufferedImage Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
/*

NOTICE


(c) 2005-2007 Sun Microsystems, Inc. All Rights Reserved.

Neither this file nor any files generated from it describe a complete specification, and they may only be used as described below. For example, no permission is given for you to incorporate this file, in whole or in part, in an implementation of a Java specification.

Sun Microsystems Inc. owns the copyright in this file and it is provided to you for informative, as opposed to normative, use. The file and any files generated from it may be used to generate other informative documentation, such as a unified set of documents of API signatures for a platform that includes technologies expressed as Java APIs. The file may also be used to produce "compilation stubs," which allow applications to be compiled and validated for such platforms.

Any work generated from this file, such as unified javadocs or compiled stub files, must be accompanied by this notice in its entirety.

This work corresponds to the API signatures of JSR 217: Personal Basis Profile 1.1. In the event of a discrepency between this work and the JSR 217 specification, which is available at http://www.jcp.org/en/jsr/detail?id=217, the latter takes precedence. */ package java.awt.image; import java.awt.Transparency; import java.awt.color.ColorSpace; import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; // import java.awt.geom.Rectangle2D; // import java.awt.geom.Point2D; import java.awt.Point; import java.awt.Rectangle; import java.util.Hashtable; import java.util.Vector; // import sun.awt.image.BytePackedRaster; // import sun.awt.image.ShortComponentRaster; // import sun.awt.image.ByteComponentRaster; // import sun.awt.image.IntegerComponentRaster; // import sun.awt.image.OffScreenImageSource; // PBP/PP // [6187206] /** * The BufferedImage subclass describes an {@link * java.awt.Image Image} with an accessible buffer of image data. * All BufferedImage objects have an upper left corner * coordinate of (0, 0). * @see ColorModel * @version 10 Feb 1997 */ public class BufferedImage extends java.awt.Image // public class BufferedImage extends java.awt.Image // implements WritableRenderedImage { /** * Image type is not recognized so it must be a customized * image. This type is only used as a return value for the getType() * method. */ public static final int TYPE_CUSTOM = 0; /** * Represents an image with 8-bit RGB color components packed into * integer pixels. The image has a {@link DirectColorModel} without * alpha. */ public static final int TYPE_INT_RGB = 1; // PBP/PP 6217661 /** * Represents an image with 8-bit RGBA color components packed into * integer pixels. The image has a DirectColorModel * with alpha. The color data in this image is considered not to be * premultiplied with alpha. */ public static final int TYPE_INT_ARGB = 2; /** * Represents an image with 8-bit RGBA color components packed into * integer pixels. The image has a DirectColorModel * with alpha. The color data in this image is considered to be * premultiplied with alpha. */ public static final int TYPE_INT_ARGB_PRE = 3; /** * Represents an image with 8-bit RGB color components, corresponding * to a Windows- or Solaris- style BGR color model, with the colors * Blue, Green, and Red packed into integer pixels. There is no alpha. * The image has a {@link DirectColorModel}. */ public static final int TYPE_INT_BGR = 4; // /** // * Represents an image with 8-bit RGB color components, corresponding // * to a Windows-style BGR color model) with the colors Blue, Green, // * and Red stored in 3 bytes. There is no alpha. The image has a // * ComponentColorModel. // */ // public static final int TYPE_3BYTE_BGR = 0; // // /** // * Represents an image with 8-bit RGBA color components with the colors // * Blue, Green, and Red stored in 3 bytes and 1 byte of alpha. The // * image has a ComponentColorModel with alpha. The // * color data in this image is considered not to be premultiplied with // * alpha. The byte data is interleaved in a single // * byte array in the order A, B, G, R // * from lower to higher byte addresses within each pixel. // */ // public static final int TYPE_4BYTE_ABGR = 0; // // /** // * Represents an image with 8-bit RGBA color components with the colors // * Blue, Green, and Red stored in 3 bytes and 1 byte of alpha. The // * image has a ComponentColorModel with alpha. The color // * data in this image is considered to be premultiplied with alpha. // * The byte data is interleaved in a single byte array in the order // * A, B, G, R from lower to higher byte addresses within each pixel. // */ // public static final int TYPE_4BYTE_ABGR_PRE = 0; /** * Represents an image with 5-6-5 RGB color components (5-bits red, * 6-bits green, 5-bits blue) with no alpha. This image has * a DirectColorModel. */ public static final int TYPE_USHORT_565_RGB = 8; /** * Represents an image with 5-5-5 RGB color components (5-bits red, * 5-bits green, 5-bits blue) with no alpha. This image has * a DirectColorModel. */ public static final int TYPE_USHORT_555_RGB = 9; // /** // * Represents a unsigned byte grayscale image, non-indexed. This // * image has a ComponentColorModel with a CS_GRAY // * {@link ColorSpace}. // */ // public static final int TYPE_BYTE_GRAY = 0; // // /** // * Represents an unsigned short grayscale image, non-indexed). This // * image has a ComponentColorModel with a CS_GRAY // * ColorSpace. // */ // public static final int TYPE_USHORT_GRAY = 0; // PBP/PP 6217661 /** * Represents an opaque byte-packed 1, 2, or 4 bit image. The * image has an {@link IndexColorModel} without alpha. * * * *

Images with 8 bits per pixel should use the image type * TYPE_BYTE_INDEXED. */ public static final int TYPE_BYTE_BINARY = 12; // PBP/PP 6217661 /** * Represents an indexed byte image. */ public static final int TYPE_BYTE_INDEXED = 13; /** * PBP: Placeholder to hide constructor. */ BufferedImage() {} // /** // * Constructs a BufferedImage of one of the predefined // * image types. The ColorSpace for the image is the // * default sRGB space. // * @param width width of the created image // * @param height height of the created image // * @param imageType type of the created image // * @see ColorSpace // * @see #TYPE_INT_RGB // * @see #TYPE_INT_ARGB // * @see #TYPE_INT_ARGB_PRE // * @see #TYPE_INT_BGR // * @see #TYPE_3BYTE_BGR // * @see #TYPE_4BYTE_ABGR // * @see #TYPE_4BYTE_ABGR_PRE // * @see #TYPE_BYTE_GRAY // * @see #TYPE_USHORT_GRAY // * @see #TYPE_BYTE_BINARY // * @see #TYPE_BYTE_INDEXED // * @see #TYPE_USHORT_565_RGB // * @see #TYPE_USHORT_555_RGB // */ // public BufferedImage(int width, int height, int imageType) { } // // /** // * Constructs a BufferedImage of one of the predefined // * image types: // * TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED. // * // *

If the image type is TYPE_BYTE_BINARY, the number of // * entries in the color model is used to determine whether the // * image should have 1, 2, or 4 bits per pixel. If the color model // * has 1 or 2 entries, the image will have 1 bit per pixel. If it // * has 3 or 4 entries, the image with have 2 bits per pixel. If // * it has between 5 and 16 entries, the image will have 4 bits per // * pixel. Otherwise, an IllegalArgumentException will be thrown. // * // * @param width width of the created image // * @param height height of the created image // * @param imageType type of the created image // * @param cm IndexColorModel of the created image // * @throws IllegalArgumentException if the imageType is not // * TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED or if the imageType is // * TYPE_BYTE_BINARY and the color map has more than 16 entries. // * @see #TYPE_BYTE_BINARY // * @see #TYPE_BYTE_INDEXED // */ // public BufferedImage(int width, int height, int imageType, IndexColorModel // cm) // { } // // /** // * Constructs a new BufferedImage with a specified // * ColorModel and Raster. If the number and // * types of bands in the SampleModel of the // * Raster do not match the number and types required by // * the ColorModel to represent its color and alpha // * components, a {@link RasterFormatException} is thrown. This // * method can multiply or divide the color Raster data by // * alpha to match the alphaPremultiplied state // * in the ColorModel. Properties for this // * BufferedImage can be established by passing // * in a {@link Hashtable} of String/Object // * pairs. // * @param cm ColorModel for the new image // * @param raster Raster for the image data // * @param isRasterPremultiplied if true, the data in // * the raster has been premultiplied with alpha. // * @param properties Hashtable of // * String/Object pairs. // * @exception RasterFormatException if the number and // * types of bands in the SampleModel of the // * Raster do not match the number and types required by // * the ColorModel to represent its color and alpha // * components. // * @exception IllegalArgumentException if // * raster is incompatible with cm // * @see ColorModel // * @see Raster // * @see WritableRaster // */ // public BufferedImage(ColorModel cm, WritableRaster raster, boolean // isRasterPremultiplied, Hashtable properties) // { } // PBP/PP /** * Returns the image type. If it is not one of the known types, * TYPE_CUSTOM is returned. * @return the image type of this BufferedImage. * @see #TYPE_INT_RGB * @see #TYPE_INT_ARGB * @see #TYPE_INT_ARGB_PRE * @see #TYPE_INT_BGR * @see #TYPE_BYTE_BINARY * @see #TYPE_BYTE_INDEXED * @see #TYPE_USHORT_565_RGB * @see #TYPE_USHORT_555_RGB * @see #TYPE_CUSTOM */ public int getType() {return 0; } /** * Returns the ColorModel. * @return the ColorModel of this * BufferedImage. */ public ColorModel getColorModel() { return null; } // /** // * Returns the {@link WritableRaster}. // * @return the WriteableRaster of this // * BufferedImage. // */ // public WritableRaster getRaster() { } // /** // * Returns a WritableRaster representing the alpha // * channel for BufferedImage objects // * with ColorModel objects that support a separate // * spatial alpha channel, such as ComponentColorModel and // * DirectColorModel. Returns null if there // * is no alpha channel associated with the ColorModel in // * this image. This method assumes that for all // * ColorModel objects other than // * IndexColorModel, if the ColorModel // * supports alpha, there is a separate alpha channel // * which is stored as the last band of image data. // * If the image uses an IndexColorModel that // * has alpha in the lookup table, this method returns // * null since there is no spatially discrete alpha // * channel. This method creates a new // * WritableRaster, but shares the data array. // * @return a WritableRaster or null if this // * BufferedImage has no alpha channel associated // * with its ColorModel. // */ // public WritableRaster getAlphaRaster() { } /** * Returns an integer pixel in the default RGB color model * (TYPE_INT_ARGB) and default sRGB colorspace. Color * conversion takes place if this default model does not match * the image ColorModel. There are only 8-bits of * precision for each color component in the returned data when using * this method. * @param x, y the coordinates of the pixel from which to get * the pixel in the default RGB color model and sRGB * color space * @return an integer pixel in the default RGB color model and * default sRGB colorspace. * @see #setRGB(int, int, int) * @see #setRGB(int, int, int, int, int[], int, int) */ public int getRGB(int x, int y) { return 0; } /** * Returns an array of integer pixels in the default RGB color model * (TYPE_INT_ARGB) and default sRGB color space, * from a portion of the image data. Color conversion takes * place if the default model does not match the image * ColorModel. There are only 8-bits of precision for * each color component in the returned data when * using this method. With a specified coordinate (x, y) in the * image, the ARGB pixel can be accessed in this way: *

     *    pixel   = rgbArray[offset + (y-startY)*scansize + (x-startX)];
     * 
* @param startX, startY the starting coordinates * @param w width of region * @param h height of region * @param rgbArray if not null, the rgb pixels are * written here * @param offset offset into the rgbArray * @param scansize scanline stride for the rgbArray * @return array of RGB pixels. * @exception IllegalArgumentException if an unknown * datatype is specified * @see #setRGB(int, int, int) * @see #setRGB(int, int, int, int, int[], int, int) */ public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) { return null; } /** * Sets a pixel in this BufferedImage to the specified * RGB value. The pixel is assumed to be in the default RGB color * model, TYPE_INT_ARGB, and default sRGB color space. For images * with an IndexColorModel, the index with the nearest * color is chosen. * @param x, y the coordinates of the pixel to set * @param rgb the RGB value * @see #getRGB(int, int) * @see #getRGB(int, int, int, int, int[], int, int) */ public synchronized void setRGB(int x, int y, int rgb) { } /** * Sets an array of integer pixels in the default RGB color model * (TYPE_INT_ARGB) and default sRGB color space, * into a portion of the image data. Color conversion takes place * if the default model does not match the image * ColorModel. There are only 8-bits of precision for * each color component in the returned data when * using this method. With a specified coordinate (x, y) in the * this image, the ARGB pixel can be accessed in this way: *
     *    pixel   = rgbArray[offset + (y-startY)*scansize + (x-startX)];
     * 
* WARNING: No dithering takes place. * * @param startX, startY the starting coordinates * @param w width of the region * @param h height of the region * @param rgbArray the rgb pixels * @param offset offset into the rgbArray * @param scansize scanline stride for the rgbArray * @see #getRGB(int, int) * @see #getRGB(int, int, int, int, int[], int, int) */ public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) { } /** * Returns the width of the BufferedImage. * @return the width of this BufferedImage */ public int getWidth() {return 0; } /** * Returns the height of the BufferedImage. * @return the height of this BufferedImage */ public int getHeight() {return 0; } /** * Returns the width of the BufferedImage. * @param observer ignored * @return the width of this BufferedImage */ public int getWidth(ImageObserver observer) {return 0; } /** * Returns the height of the BufferedImage. * @param observer ignored * @return the height of this BufferedImage */ public int getHeight(ImageObserver observer) {return 0; } /** * Returns the object that produces the pixels for the image. * @return the {@link ImageProducer} that is used to produce the * pixels for this image. * @see ImageProducer */ public ImageProducer getSource() { return null; } /** * Returns a property of the image by name. Individual property names * are defined by the various image formats. If a property is not * defined for a particular image, this method returns the * UndefinedProperty field. If the properties * for this image are not yet known, then this method returns * null and the ImageObserver object is * notified later. The property name "comment" should be used to * store an optional comment that can be presented to the user as a * description of the image, its source, or its author. * @param name the property name * @param observer the ImageObserver that receives * notification regarding image information * @return an {@link Object} that is the property referred to by the * specified name or null if the * properties of this image are not yet known. * @see ImageObserver * @see java.awt.Image#UndefinedProperty */ public Object getProperty(String name, ImageObserver observer) { return null; } /** * Returns a property of the image by name. * @param name the property name * @return an Object that is the property referred to by * the specified name. */ public Object getProperty(String name) { return null; } /** * Flushes all resources being used to cache optimization information. * The underlying pixel data is unaffected. */ public void flush() { } /** * This method returns a {@link Graphics2D}, but is here * for backwards compatibility. {@link #createGraphics() createGraphics} is more * convenient, since it is declared to return a * Graphics2D. * @return a Graphics2D, which can be used to draw into * this image. */ public java.awt.Graphics getGraphics() { return null; } /** * Creates a Graphics2D, which can be used to draw into * this BufferedImage. * @return a Graphics2D, used for drawing into this * image. */ public Graphics2D createGraphics() { return null; } /** * Returns a subimage defined by a specified rectangular region. * The returned BufferedImage shares the same * data array as the original image. * @param x, y the coordinates of the upper-left corner of the * specified rectangular region * @param w the width of the specified rectangular region * @param h the height of the specified rectangular region * @return a BufferedImage that is the subimage of this * BufferedImage. * @exception RasterFormatException if the specified * area is not contained within this BufferedImage. */ public BufferedImage getSubimage(int x, int y, int w, int h) { return null; } // /** // * Returns whether or not the alpha has been premultiplied. It // * returns true if there is no alpha since the // * default alpha is OPAQUE. // * @return true if the alpha has been premultiplied; // * false otherwise. // */ // public boolean isAlphaPremultiplied() { } // /** // * Forces the data to match the state specified in the // * isAlphaPremultiplied variable. It may multiply or // * divide the color raster data by alpha, or do nothing if the data is // * in the correct state. // * @param isAlphaPremultiplied true if the alpha has been // * premultiplied; false otherwise. // */ // public void coerceData(boolean isAlphaPremultiplied) { } /** * Returns a String representation of this * BufferedImage object and its values. * @return a String representing this * BufferedImage. */ public String toString() { return null; } // /** // * Returns a {@link Vector} of {@link RenderedImage} objects that are // * the immediate sources, not the sources of these immediate sources, // * of image data for this BufferedImage. This // * method returns null if the BufferedImage // * has no information about its immediate sources. It returns an // * empty Vector if the BufferedImage has no // * immediate sources. // * @return a Vector containing immediate sources of // * this BufferedImage object's image date, or // * null if this BufferedImage has // * no information about its immediate sources, or an empty // * Vector if this BufferedImage // * has no immediate sources. // */ // public Vector getSources() { } /** * Returns an array of names recognized by * {@link #getProperty(String) getProperty(String)} * or null, if no property names are recognized. * @return a String array containing all of the property * names that getProperty(String) recognizes; * or null if no property names are recognized. */ public String[] getPropertyNames() { return null; } // /** // * Returns the minimum x coordinate of this // * BufferedImage. This is always zero. // * @return the minimum x coordinate of this // * BufferedImage. // */ // public int getMinX() { } // // /** // * Returns the minimum y coordinate of this // * BufferedImage. This is always zero. // * @return the minimum y coordinate of this // * BufferedImage. // */ // public int getMinY() { } // /** // * Returns the SampleModel associated with this // * BufferedImage. // * @return the SampleModel of this // * BufferedImage. // */ // public SampleModel getSampleModel() { } // // /** // * Returns the number of tiles in the x direction. // * This is always one. // * @return the number of tiles in the x direction. // */ // public int getNumXTiles() { } // // /** // * Returns the number of tiles in the y direction. // * This is always one. // * @return the number of tiles in the y direction. // */ // public int getNumYTiles() { } // // /** // * Returns the minimum tile index in the x direction. // * This is always zero. // * @return the minimum tile index in the x direction. // */ // public int getMinTileX() { } // // /** // * Returns the minimum tile index in the y direction. // * This is always zero. // * @return the mininum tile index in the y direction. // */ // public int getMinTileY() { } // /** // * Returns the tile width in pixels. // * @return the tile width in pixels. // */ // public int getTileWidth() { } // // /** // * Returns the tile height in pixels. // * @return the tile height in pixels. // */ // public int getTileHeight() { } // // /** // * Returns the x offset of the tile grid relative to the origin, // * For example, the x coordinate of the location of tile // * (0, 0). This is always zero. // * @return the x offset of the tile grid. // */ // public int getTileGridXOffset() { } // // /** // * Returns the y offset of the tile grid relative to the origin, // * For example, the y coordinate of the location of tile // * (0, 0). This is always zero. // * @return the y offset of the tile grid. // */ // public int getTileGridYOffset() { } // // /** // * Returns tile (tileXtileY). Note // * that tileX and tileY are indices // * into the tile array, not pixel locations. The Raster // * that is returned is live, which means that it is updated if the // * image is changed. // * @param tileX the x index of the requested tile in the tile array // * @param tileY the y index of the requested tile in the tile array // * @return a Raster that is the tile defined by the // * arguments tileX and tileY. // * @exception ArrayIndexOutOfBoundsException if both // * tileX and tileY are not // * equal to 0 // */ // public Raster getTile(int tileX, int tileY) { } // /** // * Returns the image as one large tile. The Raster // * returned is a copy of the image data is not updated if the // * image is changed. // * @return a Raster that is a copy of the image data. // * @see #setData(Raster) // */ // public Raster getData() { } // // /** // * Computes and returns an arbitrary region of the // * BufferedImage. The Raster returned is a // * copy of the image data and is not updated if the image is // * changed. // * @param rect the region of the BufferedImage to be // * returned. // * @return a Raster that is a copy of the image data of // * the specified region of the BufferedImage // * @see #setData(Raster) // */ // public Raster getData(Rectangle rect) { } // // /** // * Computes an arbitrary rectangular region of the // * BufferedImage and copies it into a specified // * WritableRaster. The region to be computed is // * determined from the bounds of the specified // * WritableRaster. The specified // * WritableRaster must have a // * SampleModel that is compatible with this image. If // * outRaster is null, // * an appropriate WritableRaster is created. // * @param outRaster a WritableRaster to hold the returned // * part of the image, or null // * @return a reference to the supplied or created // * WritableRaster. // */ // public WritableRaster copyData(WritableRaster outRaster) { } // // /** // * Sets a rectangular region of the image to the contents of the // * specified Raster r, which is // * assumed to be in the same coordinate space as the // * BufferedImage. The operation is clipped to the bounds // * of the BufferedImage. // * @param r the specified Raster // * @see #getData // * @see #getData(Rectangle) // */ // public void setData(Raster r) { } // /** // * Adds a tile observer. If the observer is already present, // * it receives multiple notifications. // * @param to the specified {@link TileObserver} // */ // public void addTileObserver(TileObserver to) { } // // /** // * Removes a tile observer. If the observer was not registered, // * nothing happens. If the observer was registered for multiple // * notifications, it is now registered for one fewer notification. // * @param to the specified TileObserver. // */ // public void removeTileObserver(TileObserver to) { } // // /** // * Returns whether or not a tile is currently checked out for writing. // * @param tileX the x index of the tile. // * @param tileY the y index of the tile. // * @return true if the tile specified by the specified // * indices is checked out for writing; false // * otherwise. // * @exception ArrayIndexOutOfBoundsException if both // * tileX and tileY are not equal // * to 0 // */ // public boolean isTileWritable(int tileX, int tileY) { } // // /** // * Returns an array of {@link Point} objects indicating which tiles // * are checked out for writing. Returns null if none are // * checked out. // * @return a Point array that indicates the tiles that // * are checked out for writing, or null if no // * tiles are checked out for writing. // */ // public Point[] getWritableTileIndices() { } // // /** // * Returns whether or not any tile is checked out for writing. // * Semantically equivalent to // *
     // * (getWritableTileIndices() != null).
     // * 
// * @return true if any tile is checked out for writing; // * false otherwise. // */ // public boolean hasTileWriters() { } // // /** // * Checks out a tile for writing. All registered // * TileObservers are notified when a tile goes from having // * no writers to having one writer. // * @param tileX the x index of the tile // * @param tileY the y index of the tile // * @return a WritableRaster that is the tile, indicated by // * the specified indices, to be checked out for writing. // */ // public WritableRaster getWritableTile(int tileX, int tileY) { } // // /** // * Relinquishes permission to write to a tile. If the caller // * continues to write to the tile, the results are undefined. // * Calls to this method should only appear in matching pairs // * with calls to {@link #getWritableTile(int, int) getWritableTile(int, int)}. Any other leads // * to undefined results. All registered TileObservers // * are notified when a tile goes from having one writer to having no // * writers. // * @param tileX the x index of the tile // * @param tileY the y index of the tile // */ // public void releaseWritableTile(int tileX, int tileY) { } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy