2362N/A * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A class that allows the format of an image (in particular, its 0N/A * <code>SampleModel</code> and <code>ColorModel</code>) to be 0N/A * specified in a convenient manner. 0N/A * The <code>ColorModel</code> to be used as a prototype. 0N/A * A <code>SampleModel</code> to be used as a prototype. 0N/A * Cached specifiers for all of the standard 0N/A * <code>BufferedImage</code> types. 0N/A // Initialize the standard specifiers 0N/A * A constructor to be used by inner subclasses only. 0N/A * Constructs an <code>ImageTypeSpecifier</code> directly 0N/A * from a <code>ColorModel</code> and a <code>SampleModel</code>. 0N/A * It is the caller's responsibility to supply compatible 0N/A * @param colorModel a <code>ColorModel</code>. 0N/A * @param sampleModel a <code>SampleModel</code>. 0N/A * @exception IllegalArgumentException if either parameter is 0N/A * <code>null</code>. 0N/A * @exception IllegalArgumentException if <code>sampleModel</code> 0N/A * is not compatible with <code>colorModel</code>. 0N/A (
"sampleModel is incompatible with colorModel!");
0N/A * Constructs an <code>ImageTypeSpecifier</code> from a 0N/A * <code>RenderedImage</code>. If a <code>BufferedImage</code> is 0N/A * being used, one of the factory methods 0N/A * <code>createFromRenderedImage</code> or 0N/A * <code>createFromBufferedImageType</code> should be used instead in 0N/A * order to get a more accurate result. 0N/A * @param image a <code>RenderedImage</code>. 0N/A * @exception IllegalArgumentException if the argument is 0N/A * <code>null</code>. 0N/A (
"colorSpace is not of type TYPE_RGB!");
0N/A (
"Bad value for transferType!");
0N/A (
"No mask has at least 1 bit set!");
0N/A * Returns a specifier for a packed image format that will use a 0N/A * <code>DirectColorModel</code> and a packed 0N/A * <code>SampleModel</code> to store each pixel packed into in a 0N/A * single byte, short, or int. 0N/A * @param colorSpace the desired <code>ColorSpace</code>. 0N/A * @param redMask a contiguous mask indicated the position of the 0N/A * @param greenMask a contiguous mask indicated the position of the 0N/A * @param blueMask a contiguous mask indicated the position of the 0N/A * @param alphaMask a contiguous mask indicated the position of the 0N/A * @param transferType the desired <code>SampleModel</code> transfer type. 0N/A * @param isAlphaPremultiplied <code>true</code> if the color channels 0N/A * will be premultipled by the alpha channel. 0N/A * @return an <code>ImageTypeSpecifier</code> with the desired 0N/A * @exception IllegalArgumentException if <code>colorSpace</code> 0N/A * is <code>null</code>. 0N/A * @exception IllegalArgumentException if <code>colorSpace</code> 0N/A * is not of type <code>TYPE_RGB</code>. 0N/A * @exception IllegalArgumentException if no mask has at least 1 0N/A * @exception IllegalArgumentException if 0N/A * <code>transferType</code> if not one of 0N/A * <code>DataBuffer.TYPE_BYTE</code>, 0N/A * <code>DataBuffer.TYPE_USHORT</code>, or 0N/A * <code>DataBuffer.TYPE_INT</code>. 0N/A (
"bandOffsets.length is wrong!");
0N/A (
"Bad value for dataType!");
0N/A * Returns a specifier for an interleaved image format that will 0N/A * use a <code>ComponentColorModel</code> and a 0N/A * <code>PixelInterleavedSampleModel</code> to store each pixel 0N/A * component in a separate byte, short, or int. 0N/A * @param colorSpace the desired <code>ColorSpace</code>. 0N/A * @param bandOffsets an array of <code>int</code>s indicating the 0N/A * offsets for each band. 0N/A * @param dataType the desired data type, as one of the enumerations 0N/A * from the <code>DataBuffer</code> class. 0N/A * @param hasAlpha <code>true</code> if an alpha channel is desired. 0N/A * @param isAlphaPremultiplied <code>true</code> if the color channels 0N/A * will be premultipled by the alpha channel. 0N/A * @return an <code>ImageTypeSpecifier</code> with the desired 0N/A * @exception IllegalArgumentException if <code>colorSpace</code> 0N/A * is <code>null</code>. 0N/A * @exception IllegalArgumentException if <code>bandOffsets</code> 0N/A * is <code>null</code>. 0N/A * @exception IllegalArgumentException if <code>dataType</code> is 0N/A * not one of the legal <code>DataBuffer.TYPE_*</code> constants. 0N/A * @exception IllegalArgumentException if 0N/A * <code>bandOffsets.length</code> does not equal the number of 0N/A * color space components, plus 1 if <code>hasAlpha</code> is 0N/A * <code>true</code>. 0N/A (
"bankIndices.length != bandOffsets.length!");
0N/A (
"Bad value for dataType!");
0N/A (
"bandOffsets.length is wrong!");
0N/A * Returns a specifier for a banded image format that will use a 0N/A * <code>ComponentColorModel</code> and a 0N/A * <code>BandedSampleModel</code> to store each channel in a 0N/A * @param colorSpace the desired <code>ColorSpace</code>. 0N/A * @param bankIndices an array of <code>int</code>s indicating the 0N/A * bank in which each band will be stored. 0N/A * @param bandOffsets an array of <code>int</code>s indicating the 0N/A * starting offset of each band within its bank. 0N/A * @param dataType the desired data type, as one of the enumerations 0N/A * from the <code>DataBuffer</code> class. 0N/A * @param hasAlpha <code>true</code> if an alpha channel is desired. 0N/A * @param isAlphaPremultiplied <code>true</code> if the color channels 0N/A * will be premultipled by the alpha channel. 0N/A * @return an <code>ImageTypeSpecifier</code> with the desired 0N/A * @exception IllegalArgumentException if <code>colorSpace</code> 0N/A * is <code>null</code>. 0N/A * @exception IllegalArgumentException if <code>bankIndices</code> 0N/A * is <code>null</code>. 0N/A * @exception IllegalArgumentException if <code>bandOffsets</code> 0N/A * is <code>null</code>. 0N/A * @exception IllegalArgumentException if the lengths of 0N/A * <code>bankIndices</code> and <code>bandOffsets</code> differ. 0N/A * @exception IllegalArgumentException if 0N/A * <code>bandOffsets.length</code> does not equal the number of 0N/A * color space components, plus 1 if <code>hasAlpha</code> is 0N/A * <code>true</code>. 0N/A * @exception IllegalArgumentException if <code>dataType</code> is 0N/A * not one of the legal <code>DataBuffer.TYPE_*</code> constants. 0N/A (
"Bad value for dataType!");
0N/A (
"Too many bits for dataType!");
0N/A // Use component color model & sample model 0N/A * Returns a specifier for a grayscale image format that will pack 0N/A * pixels of the given bit depth into array elements of 0N/A * the specified data type. 0N/A * @param bits the number of bits per gray value (1, 2, 4, 8, or 16). 0N/A * @param dataType the desired data type, as one of the enumerations 0N/A * from the <code>DataBuffer</code> class. 0N/A * @param isSigned <code>true</code> if negative values are to 0N/A * @return an <code>ImageTypeSpecifier</code> with the desired 0N/A * @exception IllegalArgumentException if <code>bits</code> is 0N/A * not one of 1, 2, 4, 8, or 16. 0N/A * @exception IllegalArgumentException if <code>dataType</code> is 0N/A * not one of <code>DataBuffer.TYPE_BYTE</code>, 0N/A * <code>DataBuffer.TYPE_SHORT</code>, or 0N/A * <code>DataBuffer.TYPE_USHORT</code>. 0N/A * @exception IllegalArgumentException if <code>bits</code> is 0N/A * larger than the bit size of the given <code>dataType</code>. 0N/A * Returns a specifier for a grayscale plus alpha image format 0N/A * that will pack pixels of the given bit depth into array 0N/A * elements of the specified data type. 0N/A * @param bits the number of bits per gray value (1, 2, 4, 8, or 16). 0N/A * @param dataType the desired data type, as one of the enumerations 0N/A * from the <code>DataBuffer</code> class. 0N/A * @param isSigned <code>true</code> if negative values are to 0N/A * @param isAlphaPremultiplied <code>true</code> if the luminance channel 0N/A * will be premultipled by the alpha channel. 0N/A * @return an <code>ImageTypeSpecifier</code> with the desired 0N/A * @exception IllegalArgumentException if <code>bits</code> is 0N/A * not one of 1, 2, 4, 8, or 16. 0N/A * @exception IllegalArgumentException if <code>dataType</code> is 0N/A * not one of <code>DataBuffer.TYPE_BYTE</code>, 0N/A * <code>DataBuffer.TYPE_SHORT</code>, or 0N/A * <code>DataBuffer.TYPE_USHORT</code>. 0N/A * @exception IllegalArgumentException if <code>bits</code> is 0N/A * larger than the bit size of the given <code>dataType</code>. 0N/A (
"Bad value for dataType!");
0N/A (
"Too many bits for dataType!");
0N/A * Returns a specifier for an indexed-color image format that will pack 0N/A * index values of the given bit depth into array elements of 0N/A * the specified data type. 0N/A * @param redLUT an array of <code>byte</code>s containing 0N/A * the red values for each index. 0N/A * @param greenLUT an array of <code>byte</code>s containing * the 0N/A * green values for each index. 0N/A * @param blueLUT an array of <code>byte</code>s containing the 0N/A * blue values for each index. 0N/A * @param alphaLUT an array of <code>byte</code>s containing the 0N/A * alpha values for each index, or <code>null</code> to create a 0N/A * @param bits the number of bits in each index. 0N/A * @param dataType the desired output type, as one of the enumerations 0N/A * from the <code>DataBuffer</code> class. 0N/A * @return an <code>ImageTypeSpecifier</code> with the desired 0N/A * @exception IllegalArgumentException if <code>redLUT</code> is 0N/A * <code>null</code>. 0N/A * @exception IllegalArgumentException if <code>greenLUT</code> is 0N/A * <code>null</code>. 0N/A * @exception IllegalArgumentException if <code>blueLUT</code> is 0N/A * <code>null</code>. 0N/A * @exception IllegalArgumentException if <code>bits</code> is 0N/A * not one of 1, 2, 4, 8, or 16. 0N/A * @exception IllegalArgumentException if the 0N/A * non-<code>null</code> LUT parameters do not have lengths of 0N/A * exactly <code>1 << bits</code>. 0N/A * @exception IllegalArgumentException if <code>dataType</code> is 0N/A * not one of <code>DataBuffer.TYPE_BYTE</code>, 0N/A * <code>DataBuffer.TYPE_SHORT</code>, 0N/A * <code>DataBuffer.TYPE_USHORT</code>, 0N/A * or <code>DataBuffer.TYPE_INT</code>. 0N/A * @exception IllegalArgumentException if <code>bits</code> is 0N/A * larger than the bit size of the given <code>dataType</code>. 0N/A * Returns an <code>ImageTypeSpecifier</code> that encodes 0N/A * one of the standard <code>BufferedImage</code> types 0N/A * (other than <code>TYPE_CUSTOM</code>). 0N/A * @param bufferedImageType an int representing one of the standard 0N/A * <code>BufferedImage</code> types. 0N/A * @return an <code>ImageTypeSpecifier</code> with the desired 0N/A * @exception IllegalArgumentException if 0N/A * <code>bufferedImageType</code> is not one of the standard 0N/A * types, or is equal to <code>TYPE_CUSTOM</code>. 0N/A * @see java.awt.image.BufferedImage 0N/A * @see java.awt.image.BufferedImage#TYPE_INT_RGB 0N/A * @see java.awt.image.BufferedImage#TYPE_INT_ARGB 0N/A * @see java.awt.image.BufferedImage#TYPE_INT_ARGB_PRE 0N/A * @see java.awt.image.BufferedImage#TYPE_INT_BGR 0N/A * @see java.awt.image.BufferedImage#TYPE_3BYTE_BGR 0N/A * @see java.awt.image.BufferedImage#TYPE_4BYTE_ABGR 0N/A * @see java.awt.image.BufferedImage#TYPE_4BYTE_ABGR_PRE 0N/A * @see java.awt.image.BufferedImage#TYPE_USHORT_565_RGB 0N/A * @see java.awt.image.BufferedImage#TYPE_USHORT_555_RGB 0N/A * @see java.awt.image.BufferedImage#TYPE_BYTE_GRAY 0N/A * @see java.awt.image.BufferedImage#TYPE_USHORT_GRAY 0N/A * @see java.awt.image.BufferedImage#TYPE_BYTE_BINARY 0N/A * @see java.awt.image.BufferedImage#TYPE_BYTE_INDEXED 0N/A * Returns an <code>ImageTypeSpecifier</code> that encodes the 0N/A * layout of a <code>RenderedImage</code> (which may be a 0N/A * <code>BufferedImage</code>). 0N/A * @param image a <code>RenderedImage</code>. 0N/A * @return an <code>ImageTypeSpecifier</code> with the desired 0N/A * @exception IllegalArgumentException if <code>image</code> is 0N/A * <code>null</code>. 0N/A * Returns an int containing one of the enumerated constant values 0N/A * describing image formats from <code>BufferedImage</code>. 0N/A * @return an <code>int</code> representing a 0N/A * <code>BufferedImage</code> type. 0N/A * @see java.awt.image.BufferedImage 0N/A * @see java.awt.image.BufferedImage#TYPE_CUSTOM 0N/A * @see java.awt.image.BufferedImage#TYPE_INT_RGB 0N/A * @see java.awt.image.BufferedImage#TYPE_INT_ARGB 0N/A * @see java.awt.image.BufferedImage#TYPE_INT_ARGB_PRE 0N/A * @see java.awt.image.BufferedImage#TYPE_INT_BGR 0N/A * @see java.awt.image.BufferedImage#TYPE_3BYTE_BGR 0N/A * @see java.awt.image.BufferedImage#TYPE_4BYTE_ABGR 0N/A * @see java.awt.image.BufferedImage#TYPE_4BYTE_ABGR_PRE 0N/A * @see java.awt.image.BufferedImage#TYPE_USHORT_565_RGB 0N/A * @see java.awt.image.BufferedImage#TYPE_USHORT_555_RGB 0N/A * @see java.awt.image.BufferedImage#TYPE_BYTE_GRAY 0N/A * @see java.awt.image.BufferedImage#TYPE_USHORT_GRAY 0N/A * @see java.awt.image.BufferedImage#TYPE_BYTE_BINARY 0N/A * @see java.awt.image.BufferedImage#TYPE_BYTE_INDEXED 0N/A * Return the number of color components 0N/A * specified by this object. This is the same value as returned by 0N/A * <code>ColorModel.getNumComponents</code> 0N/A * @return the number of components in the image. 0N/A * Return the number of bands 0N/A * specified by this object. This is the same value as returned by 0N/A * <code>SampleModel.getNumBands</code> 0N/A * @return the number of bands in the image. 0N/A * Return the number of bits used to represent samples of the given band. 0N/A * @param band the index of the band to be queried, as an 0N/A * @return an int specifying a number of bits. 0N/A * @exception IllegalArgumentException if <code>band</code> is 0N/A * negative or greater than the largest band index. 0N/A * Returns a <code>SampleModel</code> based on the settings 0N/A * encapsulated within this object. The width and height of the 0N/A * <code>SampleModel</code> will be set to arbitrary values. 0N/A * @return a <code>SampleModel</code> with arbitrary dimensions. 0N/A * Returns a <code>SampleModel</code> based on the settings 0N/A * encapsulated within this object. The width and height of the 0N/A * <code>SampleModel</code> will be set to the supplied values. 0N/A * @param width the desired width of the returned <code>SampleModel</code>. 0N/A * @param height the desired height of the returned 0N/A * <code>SampleModel</code>. 0N/A * @return a <code>SampleModel</code> with the given dimensions. 0N/A * @exception IllegalArgumentException if either <code>width</code> or 0N/A * <code>height</code> are negative or zero. 0N/A * @exception IllegalArgumentException if the product of 0N/A * <code>width</code> and <code>height</code> is greater than 0N/A * <code>Integer.MAX_VALUE</code> 0N/A (
"width*height > Integer.MAX_VALUE!");
0N/A * Returns the <code>ColorModel</code> specified by this object. 0N/A * @return a <code>ColorModel</code>. 0N/A * Creates a <code>BufferedImage</code> with a given width and 0N/A * height according to the specification embodied in this object. 0N/A * @param width the desired width of the returned 0N/A * <code>BufferedImage</code>. 0N/A * @param height the desired height of the returned 0N/A * <code>BufferedImage</code>. 0N/A * @return a new <code>BufferedImage</code> 0N/A * @exception IllegalArgumentException if either <code>width</code> or 0N/A * <code>height</code> are negative or zero. 0N/A * @exception IllegalArgumentException if the product of 0N/A * <code>width</code> and <code>height</code> is greater than 0N/A * <code>Integer.MAX_VALUE</code>, or if the number of array 0N/A * elements needed to store the image is greater than 0N/A * <code>Integer.MAX_VALUE</code>. 0N/A // Exception most likely thrown from a DataBuffer constructor 0N/A (
"Array size > Integer.MAX_VALUE!");
0N/A * Returns <code>true</code> if the given <code>Object</code> is 0N/A * an <code>ImageTypeSpecifier</code> and has a 0N/A * <code>SampleModel</code> and <code>ColorModel</code> that are 0N/A * equal to those of this object. 0N/A * @param o the <code>Object</code> to be compared for equality. 0N/A * @return <code>true</code> if the given object is an equivalent 0N/A * <code>ImageTypeSpecifier</code>. 0N/A * Returns the hash code for this ImageTypeSpecifier. 0N/A * @return a hash code for this ImageTypeSpecifier 989N/A new int[] {
3,
2,
1,
0 },
989N/A new int[] {
3,
2,
1,
0 },