A class that allows the format of an image (in particular, its SampleModel and ColorModel) to be specified in a convenient manner.
@version
0.5
Constructs an ImageTypeSpecifier directly from a ColorModel and a SampleModel. It is the caller's responsibility to supply compatible parameters.
Parameters
colorModela ColorModel.
sampleModela SampleModel.
Throws
IllegalArgumentExceptionif either parameter is null.
IllegalArgumentExceptionif sampleModel is not compatible with colorModel.
Constructs an ImageTypeSpecifier from a RenderedImage. If a BufferedImage is being used, one of the factory methods createFromRenderedImage or createFromBufferedImageType should be used instead in order to get a more accurate result.
Parameters
imagea RenderedImage.
Throws
IllegalArgumentExceptionif the argument is null.
Returns a specifier for a banded image format that will use a ComponentColorModel and a BandedSampleModel to store each channel in a separate array.
Parameters
colorSpacethe desired ColorSpace.
bankIndicesan array of ints indicating the bank in which each band will be stored.
bandOffsetsan array of ints indicating the starting offset of each band within its bank.
dataTypethe desired data type, as one of the enumerations from the DataBuffer class.
hasAlphatrue if an alpha channel is desired.
isAlphaPremultipliedtrue if the color channels will be premultipled by the alpha channel.
Return
an ImageTypeSpecifier with the desired characteristics.
Throws
IllegalArgumentExceptionif colorSpace is null.
IllegalArgumentExceptionif bankIndices is null.
IllegalArgumentExceptionif bandOffsets is null.
IllegalArgumentExceptionif the lengths of bankIndices and bandOffsets differ.
IllegalArgumentExceptionif bandOffsets.length does not equal the number of color space components, plus 1 if hasAlpha is true.
IllegalArgumentExceptionif dataType is not one of the legal DataBuffer.TYPE_* constants.
Creates a BufferedImage with a given width and height according to the specification embodied in this object.
Parameters
widththe desired width of the returned BufferedImage.
heightthe desired height of the returned BufferedImage.
Return
a new BufferedImage
Throws
IllegalArgumentExceptionif either width or height are negative or zero.
IllegalArgumentExceptionif the product of width and height is greater than Integer.MAX_VALUE, or if the number of array elements needed to store the image is greater than Integer.MAX_VALUE.
Returns an ImageTypeSpecifier that encodes one of the standard BufferedImage types (other than TYPE_CUSTOM).
Returns an ImageTypeSpecifier that encodes the layout of a RenderedImage (which may be a BufferedImage).
Parameters
imagea RenderedImage.
Return
an ImageTypeSpecifier with the desired characteristics.
Throws
IllegalArgumentExceptionif image is null.
Returns a specifier for a grayscale image format that will pack pixels of the given bit depth into array elements of the specified data type.
Parameters
bitsthe number of bits per gray value (1, 2, 4, 8, or 16).
dataTypethe desired data type, as one of the enumerations from the DataBuffer class.
isSignedtrue if negative values are to be represented.
Return
an ImageTypeSpecifier with the desired characteristics.
Throws
IllegalArgumentExceptionif bits is not one of 1, 2, 4, 8, or 16.
IllegalArgumentExceptionif dataType is not one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT, or DataBuffer.TYPE_USHORT.
IllegalArgumentExceptionif bits is larger than the bit size of the given dataType.
Returns a specifier for a grayscale plus alpha image format that will pack pixels of the given bit depth into array elements of the specified data type.
Parameters
bitsthe number of bits per gray value (1, 2, 4, 8, or 16).
dataTypethe desired data type, as one of the enumerations from the DataBuffer class.
isSignedtrue if negative values are to be represented.
isAlphaPremultipliedtrue if the luminance channel will be premultipled by the alpha channel.
Return
an ImageTypeSpecifier with the desired characteristics.
Throws
IllegalArgumentExceptionif bits is not one of 1, 2, 4, 8, or 16.
IllegalArgumentExceptionif dataType is not one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT, or DataBuffer.TYPE_USHORT.
IllegalArgumentExceptionif bits is larger than the bit size of the given dataType.
Returns a specifier for an indexed-color image format that will pack index values of the given bit depth into array elements of the specified data type.
Parameters
redLUTan array of bytes containing the red values for each index.
greenLUTan array of bytes containing * the green values for each index.
blueLUTan array of bytes containing the blue values for each index.
alphaLUTan array of bytes containing the alpha values for each index, or null to create a fully opaque LUT.
bitsthe number of bits in each index.
dataTypethe desired output type, as one of the enumerations from the DataBuffer class.
Return
an ImageTypeSpecifier with the desired characteristics.
Throws
IllegalArgumentExceptionif redLUT is null.
IllegalArgumentExceptionif greenLUT is null.
IllegalArgumentExceptionif blueLUT is null.
IllegalArgumentExceptionif bits is not one of 1, 2, 4, 8, or 16.
IllegalArgumentExceptionif the non-null LUT parameters do not have lengths of exactly 1 << bits.
IllegalArgumentExceptionif dataType is not one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_SHORT, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT.
IllegalArgumentExceptionif bits is larger than the bit size of the given dataType.
Returns a specifier for an interleaved image format that will use a ComponentColorModel and a PixelInterleavedSampleModel to store each pixel component in a separate byte, short, or int.
Parameters
colorSpacethe desired ColorSpace.
bandOffsetsan array of ints indicating the offsets for each band.
dataTypethe desired data type, as one of the enumerations from the DataBuffer class.
hasAlphatrue if an alpha channel is desired.
isAlphaPremultipliedtrue if the color channels will be premultipled by the alpha channel.
Return
an ImageTypeSpecifier with the desired characteristics.
Throws
IllegalArgumentExceptionif colorSpace is null.
IllegalArgumentExceptionif bandOffsets is null.
IllegalArgumentExceptionif dataType is not one of the legal DataBuffer.TYPE_* constants.
IllegalArgumentExceptionif bandOffsets.length does not equal the number of color space components, plus 1 if hasAlpha is true.
Returns a specifier for a packed image format that will use a DirectColorModel and a packed SampleModel to store each pixel packed into in a single byte, short, or int.
Parameters
colorSpacethe desired ColorSpace.
redMaska contiguous mask indicated the position of the red channel.
greenMaska contiguous mask indicated the position of the green channel.
blueMaska contiguous mask indicated the position of the blue channel.
alphaMaska contiguous mask indicated the position of the alpha channel.
transferTypethe desired SampleModel transfer type.
isAlphaPremultipliedtrue if the color channels will be premultipled by the alpha channel.
Return
an ImageTypeSpecifier with the desired characteristics.
Throws
IllegalArgumentExceptionif colorSpace is null.
IllegalArgumentExceptionif colorSpace is not of type TYPE_RGB.
IllegalArgumentExceptionif no mask has at least 1 bit set.
IllegalArgumentExceptionif transferType if not one of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT, or DataBuffer.TYPE_INT.
Returns true if the given Object is an ImageTypeSpecifier and has a SampleModel and ColorModel that are equal to those of this object.
Parameters
othe Object to be compared for equality.
Return
true if the given object is an equivalent ImageTypeSpecifier.
Return the number of bits used to represent samples of the given band.
Parameters
bandthe index of the band to be queried, as an int.
Return
an int specifying a number of bits.
Throws
IllegalArgumentExceptionif band is negative or greater than the largest band index.
Returns an int containing one of the enumerated constant values describing image formats from BufferedImage.
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
Returns the ColorModel specified by this object.
Return
a ColorModel.
Return the number of bands specified by this object. This is the same value as returned by SampleModel.getNumBands
Return
the number of bands in the image.
Return the number of color components specified by this object. This is the same value as returned by ColorModel.getNumComponents
Return
the number of components in the image.
Returns a SampleModel based on the settings encapsulated within this object. The width and height of the SampleModel will be set to arbitrary values.
Return
a SampleModel with arbitrary dimensions.
Returns a SampleModel based on the settings encapsulated within this object. The width and height of the SampleModel will be set to the supplied values.
Parameters
widththe desired width of the returned SampleModel.
heightthe desired height of the returned SampleModel.
Return
a SampleModel with the given dimensions.
Throws
IllegalArgumentExceptionif either width or height are negative or zero.
IllegalArgumentExceptionif the product of width and height is greater than Integer.MAX_VALUE
Returns the hash code for this ImageTypeSpecifier.
Return
a hash code for this ImageTypeSpecifier
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
Return
a string representation of the object.
Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait();
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Throws
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

  • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
  • Some other thread invokes the notifyAll method for this object.
  • Some other thread interrupts thread T.
  • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout);
         ... // Perform action appropriate to condition
     }
 
(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Parameters
timeoutthe maximum time to wait in milliseconds.
Throws
IllegalArgumentExceptionif the value of timeout is negative.
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

 1000000*timeout+nanos

In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

  • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
  • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout, nanos);
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Parameters
timeoutthe maximum time to wait in milliseconds.
nanosadditional time, in nanoseconds range 0-999999.
Throws
IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.