net.grelf.grip
Class ImBase

java.lang.Object
  extended by net.grelf.grip.ImBase
Direct Known Subclasses:
Im

public class ImBase
extends java.lang.Object

Basic image stuff that can be used in applications/applets other than GRIP. Can contain either a BufferedImage or an Image.


Field Summary
protected static int DEFAULT_COLOUR_IMAGE_TYPE
           
protected static int DEFAULT_MONO_IMAGE_TYPE
           
protected  javax.imageio.IIOImage iioi
          Wraps image, thumbnails and image metadata.
protected  Image image
          Either this field or iioi must be null: an Im has either a BufferedImage or an Image.
static float SCREEN_FRACTION
          Initial size factor for displaying an image.
 
Constructor Summary
ImBase(java.awt.image.BufferedImage bim)
           
ImBase(javax.imageio.IIOImage iioi)
           
ImBase(Image image)
           
ImBase(int width, int height, boolean compatibleWithDisplay)
          If the boolean is false an image of type java.awt.image.BufferedImage.TYPE_INT_RGB will be created.
ImBase(int width, int height, boolean compatibleWithDisplay, boolean monochrome)
           
ImBase(int width, int height, java.awt.image.ColorModel cm)
           
 
Method Summary
static java.awt.image.BufferedImage create16BitImage(int width, int height, java.awt.image.BufferedImage srcBim)
          Create a new BufferedImage with 16 bits per channel and ColorModel derived from given srcBim.
static java.awt.image.BufferedImage create16BitImage(int width, int height, int nBands)
          Create a new BufferedImage with 16 bits per channel and linear ColorModel.
 Image getAccumulator()
          Deprecated. 
 java.awt.image.BufferedImage getBufferedImage()
          Get a reference to the BufferedImage in this ImBase object (will be null if there is an Image instead).
static java.awt.GraphicsConfiguration getGraphicsConfiguration()
          Get a reference to the GraphicsConfiguration object, which is the default one for the display system.
 int getHeight()
          Get the height of the main BufferedImage or Image.
 Image getImage()
          Use getImage () instead.
 java.lang.String getImageTypeAsString()
          For displaying image information, get its java.awt.image.BufferedImage type constant name.
static java.lang.String getImageTypeAsString(java.awt.image.BufferedImage bim)
          For displaying image information, get the given image's java.awt.image.BufferedImage type constant name.
 int getMaxLevel()
          Get the maximum level which can occur for each channel in the image or accumulator.
static int getMaxLevel(java.awt.image.BufferedImage bim)
          Get the maximum level which can occur for each channel in the image.
 Metadata getMetadata()
          Get metadata associated with the image.
 int getNBands()
          Get the number of bands (channels) in the image or accumulator.
static int getNBands(java.awt.image.BufferedImage bim)
          Get the number of bands (channels) in the image.
 int getNBits()
          Get the number of bits in every channel of the BufferedImage or Image.
static int getNBits(java.awt.image.BufferedImage bim)
          Get the number of bits in every channel of the image.
static int getNBits(int maxLevel)
          Get the number of bits which would accommodate the given maximum level.
 java.awt.image.BufferedImage getThumbnail()
          Get a reference to the first thumbnail loaded with this image (if any).
 int getWidth()
          Get the width of the main BufferedImage or Image.
 boolean hasAccumulator()
          Deprecated. 
 boolean hasImage()
           
 ImBase scaleDown(int factor)
          Return a new BufferedImage-based object which is compatible with the display and contains the data from the current BufferedImage or Image scaled down by an integer factor in both x and y.
 void setAccumulator(Image image)
          Deprecated. 
 void setBufferedImage(java.awt.image.BufferedImage bim)
          Sets the image to the given BufferedImage (may be null) and sets the Image to null.
 void setImage(java.awt.image.BufferedImage bim)
          Deprecated. 
 void setImage(Image image)
          Sets the accumulator to the given Accumulator (may be null) and sets the (Buffered)Image to null.
 void setMetadata(Metadata theData)
          Associate metadata with the image - only if it is a BufferedImage.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCREEN_FRACTION

public static final float SCREEN_FRACTION
Initial size factor for displaying an image.

See Also:
Constant Field Values

DEFAULT_COLOUR_IMAGE_TYPE

protected static final int DEFAULT_COLOUR_IMAGE_TYPE
See Also:
Constant Field Values

DEFAULT_MONO_IMAGE_TYPE

protected static final int DEFAULT_MONO_IMAGE_TYPE
See Also:
Constant Field Values

iioi

protected javax.imageio.IIOImage iioi
Wraps image, thumbnails and image metadata. Either this field or image must be null: an Im has either a BufferedImage or an Image.


image

protected Image image
Either this field or iioi must be null: an Im has either a BufferedImage or an Image.

Constructor Detail

ImBase

public ImBase(int width,
              int height,
              boolean compatibleWithDisplay)
If the boolean is false an image of type java.awt.image.BufferedImage.TYPE_INT_RGB will be created.


ImBase

public ImBase(int width,
              int height,
              boolean compatibleWithDisplay,
              boolean monochrome)

ImBase

public ImBase(int width,
              int height,
              java.awt.image.ColorModel cm)

ImBase

public ImBase(java.awt.image.BufferedImage bim)

ImBase

public ImBase(javax.imageio.IIOImage iioi)

ImBase

public ImBase(Image image)
Method Detail

hasImage

public boolean hasImage()

hasAccumulator

@Deprecated
public boolean hasAccumulator()
Deprecated. 

Use hasImage() imstead. Retained for backwards compatibility.


getMetadata

public Metadata getMetadata()
Get metadata associated with the image. Null if none.


setMetadata

public void setMetadata(Metadata theData)
Associate metadata with the image - only if it is a BufferedImage.


getBufferedImage

public java.awt.image.BufferedImage getBufferedImage()
Get a reference to the BufferedImage in this ImBase object (will be null if there is an Image instead).


setImage

@Deprecated
public void setImage(java.awt.image.BufferedImage bim)
Deprecated. 

Use setBufferedImage() instead.


setBufferedImage

public void setBufferedImage(java.awt.image.BufferedImage bim)
Sets the image to the given BufferedImage (may be null) and sets the Image to null.


getAccumulator

@Deprecated
public Image getAccumulator()
Deprecated. 

Use getImage() instead.


getImage

public Image getImage()
Use getImage () instead. Get a reference to the Image in this ImBase object (will be null if there is a BufferedImage instead).


setAccumulator

@Deprecated
public void setAccumulator(Image image)
Deprecated. 

Use setImage() instead.


setImage

public void setImage(Image image)
Sets the accumulator to the given Accumulator (may be null) and sets the (Buffered)Image to null.


getImageTypeAsString

public java.lang.String getImageTypeAsString()
For displaying image information, get its java.awt.image.BufferedImage type constant name.


getImageTypeAsString

public static java.lang.String getImageTypeAsString(java.awt.image.BufferedImage bim)
For displaying image information, get the given image's java.awt.image.BufferedImage type constant name.


getThumbnail

public java.awt.image.BufferedImage getThumbnail()
Get a reference to the first thumbnail loaded with this image (if any). Returns null if no thumbnail is available.


getGraphicsConfiguration

public static java.awt.GraphicsConfiguration getGraphicsConfiguration()
Get a reference to the GraphicsConfiguration object, which is the default one for the display system.


getMaxLevel

public int getMaxLevel()
Get the maximum level which can occur for each channel in the image or accumulator.


getMaxLevel

public static int getMaxLevel(java.awt.image.BufferedImage bim)
Get the maximum level which can occur for each channel in the image.


getNBits

public static int getNBits(int maxLevel)
Get the number of bits which would accommodate the given maximum level. Eg, 65535 returns 16.


getNBands

public int getNBands()
Get the number of bands (channels) in the image or accumulator.


getNBands

public static int getNBands(java.awt.image.BufferedImage bim)
Get the number of bands (channels) in the image.


getNBits

public int getNBits()
Get the number of bits in every channel of the BufferedImage or Image. Only likely to be 8, 16 or 32.


getNBits

public static int getNBits(java.awt.image.BufferedImage bim)
Get the number of bits in every channel of the image. Only likely to be 8 or 16.


getWidth

public int getWidth()
Get the width of the main BufferedImage or Image.


getHeight

public int getHeight()
Get the height of the main BufferedImage or Image.


create16BitImage

public static java.awt.image.BufferedImage create16BitImage(int width,
                                                            int height,
                                                            java.awt.image.BufferedImage srcBim)
Create a new BufferedImage with 16 bits per channel and ColorModel derived from given srcBim. Checks free memory and tells user if it cannot be done.


create16BitImage

public static java.awt.image.BufferedImage create16BitImage(int width,
                                                            int height,
                                                            int nBands)
Create a new BufferedImage with 16 bits per channel and linear ColorModel. Checks free memory and tells user if it cannot be done.


scaleDown

public ImBase scaleDown(int factor)
Return a new BufferedImage-based object which is compatible with the display and contains the data from the current BufferedImage or Image scaled down by an integer factor in both x and y.