ach.image
Class ImageInfo

java.lang.Object
  extended byach.image.ImageInfo
All Implemented Interfaces:
java.lang.Runnable

public class ImageInfo
extends java.lang.Object
implements java.lang.Runnable

ImageInfo.java
Copyright (c) 1997, 2010 Helge Hackbarth, All Rights Reserved.
A class describing properties of an image according to tags defined in the TIFF file format.
NOTE: Most of the image information fields like width, height, xResolution, yResolution, maxGrayLevel, bitsPerSample etc. are only set for TIFF files. If you need this information also for images read from GIF or JPEG files, please refer to the methods / property fields available through the EMemImageSource-class in this package.

THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.


Field Summary
 java.lang.String annotationExtension
          Filename extension that is expected for annotation file (default: ".xml")
 java.lang.String annotations
          Annotations (XML formatted string) for the image
static boolean annotationsAllowed
          Flag if annotations are allowed to be read for the image (static, so it controls all instances)
 java.lang.String artist
          Artist that created that image
 short bitsPerSample
          Bits per sample
static byte BLUEIDX
          Index for RGB-Palette
 byte[] bytePixels
          Array of bytes containing image data (if palette image with more than 16 colors)
 int bytesPerRow
          Number of bytes per row (if stored bitwise packed)
static int CCITTFAXG3
          Compression type
static int CCITTFAXG4
          Compression type
static int CCITTG3
          Compression type
static byte CMYK
          Photometric interpretation
 java.awt.image.ColorModel colorModel
          Current Java style ColorModel
 int compression
          Current compression type
 java.lang.String errorMsg
          Error message of last operation
static byte GIF87
          Sub-format for image data
static byte GIF89A
          Sub-format for image data
static byte GRAYBLACK0
          Photometric interpretation
 short[] grayRespCurve
          Gray response curve (allows a nonlinear gray distribution)
 short grayRespUnit
          Gray response unit (controls interpretation of gray response curve)
static byte GRAYWHITE0
          Photometric interpretation
static byte GREENIDX
          Index for RGB-Palette
 boolean hasChanged
          Flag if image was modified
 int height
          Vertical number of pixels
static byte ifBMP
          Predefined image file format
static byte ifGIF
          Predefined image file format
static byte ifJPG
          Predefined image file format
static byte ifPNG
          Predefined image file format
static byte ifTIF
          Predefined image file format
static byte ifUNKNOWN
          Predefined image file format
 java.lang.String imageDescription
          Description of the image
 java.lang.String imageNameMasks
          Name-masks for file dialog (seperated by pathSeparatorChar)
 byte[] imgFileBA
          ByteArray that might contain the image-file as byte array (alternative to passing the file as imgName or imgURL)
 byte imgFormat
          Current image file format
 java.lang.String imgName
          (Path-)name of image file
 java.net.URL imgURL
          URL of image file (read from local file if URL == null)
static byte INTEL
          Sub-format for image data
 int[] intPixels
          Array of integers containing image data (if truecolor image)
static int JPEG
          Compression type
 com.sun.image.codec.jpeg.JPEGDecodeParam jpegDecodeParam
           
static int LZW
          Compression type
 short maxGrayLevel
          Maximum gray level (e.g. 15 for 4 bit images, 255 for 8 bit images)
static byte MOTOROLA
          Sub-format for image data
 int numPages
          Number of pages.
 short orientation
          Orientation of the image orientation values: 1 NOP
2 mirror horizontally
3 rotate 180 degree
4 rotate 180 degree and mirror horizontally
5 rotate 270 degree anticlockwise and mirror horizontally
6 rotate 270 degree anticlockwise
7 rotate 90 degree anticlockwise and mirror horizontally
8 rotate 90 degree anticlockwise
static int PACKBITS
          Compression type
 byte[] packedPixels
          Array of bytes containing packed image data (if palette image with 16 or less colors)
 int page
          Current of page number within a multi document TIFF file (counting start at 1).
static byte PALETTECOL
          Photometric interpretation
 short photometricInt
          Current photometric interpretation
 short planarConfig
          Sample values continously or seperated in planes
 short predictor
          Predictor controls whether the image data are horizontally differentiated
static byte REDIDX
          Index for RGB-Palette
static byte RGB
          Photometric interpretation
 byte[] rgbPalette
          RGB-palette (array of 256 * 3 bytes for red, green and blue. 0 <= red, green, blue <= 255.
 short samplePlanes
          Number of sample planes (in rare cases red, green and blue samples might be stored in seperate planes).
 short samplesPerPixel
          Samples per pixel (e.g. 3 for RGB true color images)
static byte sfUNKNOWN
          Sub-format for image data
 ShapeList[] shapeLists
          Array of ShapeLists that contains annotations parsed into vector graphic objects.
 java.lang.String software
          Software that was used to create that image
 byte subFormat
          Current image file subformat (set to ifGIF / ifTIF / ...).
static byte TRANSPARMASK
          Photometric interpretation
static int UNCOMPRESSED
          Compression type
 int width
          Horizontal number of pixels
 Rational xResolution
          Horizontal resolution in pixels per inch
static byte YCBCR
          Photometric interpretation
 Rational yResolution
          Vertical resolution in pixels per inch
 
Constructor Summary
ImageInfo()
          Constructor for ImageInfo
 
Method Summary
 int calcPixelSize()
          calulate real number of bits per pixel according to mapSize of ColorModel Note: ColorModel.getPixelSize() usually reports 8 even if mapsize < 256 (especially required for JDK 1.2)
 void createImageProducer()
          Create an image producer from imgName or imgUrl.
 void detectImageFormat()
          Method to detect image format from file extension
 void getAnnotations()
          Load annotation file (expected with same name like imgName or imgUrl but with extension ".xml").
 void run()
          Allows to run the creation of an image producer asynchronously as seperate thread.
 void setAsynchronousTools(java.awt.Toolkit toolkit, ImgProdObserver imgProdObserver, boolean asyncMode)
          Define all necessary parameters to be able to start image production as an asynchronous thread afterwards.
 void setDefaults()
          Set default values for important image info variables
 java.lang.String toString()
          Returns information about the image
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ifUNKNOWN

public static final byte ifUNKNOWN
Predefined image file format

See Also:
Constant Field Values

ifGIF

public static final byte ifGIF
Predefined image file format

See Also:
Constant Field Values

ifJPG

public static final byte ifJPG
Predefined image file format

See Also:
Constant Field Values

ifBMP

public static final byte ifBMP
Predefined image file format

See Also:
Constant Field Values

ifTIF

public static final byte ifTIF
Predefined image file format

See Also:
Constant Field Values

ifPNG

public static final byte ifPNG
Predefined image file format

See Also:
Constant Field Values

imageNameMasks

public java.lang.String imageNameMasks
Name-masks for file dialog (seperated by pathSeparatorChar)


annotationExtension

public java.lang.String annotationExtension
Filename extension that is expected for annotation file (default: ".xml")


sfUNKNOWN

public static final byte sfUNKNOWN
Sub-format for image data

See Also:
Constant Field Values

INTEL

public static final byte INTEL
Sub-format for image data

See Also:
Constant Field Values

MOTOROLA

public static final byte MOTOROLA
Sub-format for image data

See Also:
Constant Field Values

GIF87

public static final byte GIF87
Sub-format for image data

See Also:
Constant Field Values

GIF89A

public static final byte GIF89A
Sub-format for image data

See Also:
Constant Field Values

UNCOMPRESSED

public static final int UNCOMPRESSED
Compression type

See Also:
Constant Field Values

CCITTG3

public static final int CCITTG3
Compression type

See Also:
Constant Field Values

CCITTFAXG3

public static final int CCITTFAXG3
Compression type

See Also:
Constant Field Values

CCITTFAXG4

public static final int CCITTFAXG4
Compression type

See Also:
Constant Field Values

LZW

public static final int LZW
Compression type

See Also:
Constant Field Values

JPEG

public static final int JPEG
Compression type

See Also:
Constant Field Values

PACKBITS

public static final int PACKBITS
Compression type

See Also:
Constant Field Values

GRAYWHITE0

public static final byte GRAYWHITE0
Photometric interpretation

See Also:
Constant Field Values

GRAYBLACK0

public static final byte GRAYBLACK0
Photometric interpretation

See Also:
Constant Field Values

RGB

public static final byte RGB
Photometric interpretation

See Also:
Constant Field Values

PALETTECOL

public static final byte PALETTECOL
Photometric interpretation

See Also:
Constant Field Values

TRANSPARMASK

public static final byte TRANSPARMASK
Photometric interpretation

See Also:
Constant Field Values

CMYK

public static final byte CMYK
Photometric interpretation

See Also:
Constant Field Values

YCBCR

public static final byte YCBCR
Photometric interpretation

See Also:
Constant Field Values

REDIDX

public static final byte REDIDX
Index for RGB-Palette

See Also:
Constant Field Values

GREENIDX

public static final byte GREENIDX
Index for RGB-Palette

See Also:
Constant Field Values

BLUEIDX

public static final byte BLUEIDX
Index for RGB-Palette

See Also:
Constant Field Values

imgName

public java.lang.String imgName
(Path-)name of image file


imgURL

public java.net.URL imgURL
URL of image file (read from local file if URL == null)


imgFileBA

public byte[] imgFileBA
ByteArray that might contain the image-file as byte array (alternative to passing the file as imgName or imgURL)


imgFormat

public byte imgFormat
Current image file format


subFormat

public byte subFormat
Current image file subformat (set to ifGIF / ifTIF / ...).


numPages

public int numPages
Number of pages. TIFF files might contain more than one page.


page

public int page
Current of page number within a multi document TIFF file (counting start at 1).


hasChanged

public boolean hasChanged
Flag if image was modified


width

public int width
Horizontal number of pixels


height

public int height
Vertical number of pixels


xResolution

public Rational xResolution
Horizontal resolution in pixels per inch


yResolution

public Rational yResolution
Vertical resolution in pixels per inch


maxGrayLevel

public short maxGrayLevel
Maximum gray level (e.g. 15 for 4 bit images, 255 for 8 bit images)


bytesPerRow

public int bytesPerRow
Number of bytes per row (if stored bitwise packed)


bitsPerSample

public short bitsPerSample
Bits per sample

See Also:
samplesPerPixel

samplesPerPixel

public short samplesPerPixel
Samples per pixel (e.g. 3 for RGB true color images)


samplePlanes

public short samplePlanes
Number of sample planes (in rare cases red, green and blue samples might be stored in seperate planes).


compression

public int compression
Current compression type


predictor

public short predictor
Predictor controls whether the image data are horizontally differentiated


photometricInt

public short photometricInt
Current photometric interpretation


planarConfig

public short planarConfig
Sample values continously or seperated in planes

See Also:
samplePlanes

grayRespUnit

public short grayRespUnit
Gray response unit (controls interpretation of gray response curve)


grayRespCurve

public short[] grayRespCurve
Gray response curve (allows a nonlinear gray distribution)


rgbPalette

public byte[] rgbPalette
RGB-palette (array of 256 * 3 bytes for red, green and blue. 0 <= red, green, blue <= 255.


artist

public java.lang.String artist
Artist that created that image


software

public java.lang.String software
Software that was used to create that image


imageDescription

public java.lang.String imageDescription
Description of the image


annotationsAllowed

public static boolean annotationsAllowed
Flag if annotations are allowed to be read for the image (static, so it controls all instances)


annotations

public java.lang.String annotations
Annotations (XML formatted string) for the image


shapeLists

public ShapeList[] shapeLists
Array of ShapeLists that contains annotations parsed into vector graphic objects. The array contains one Shapelist for each page if ImageInfo represents a multipage file.


orientation

public short orientation
Orientation of the image orientation values: 1 NOP
2 mirror horizontally
3 rotate 180 degree
4 rotate 180 degree and mirror horizontally
5 rotate 270 degree anticlockwise and mirror horizontally
6 rotate 270 degree anticlockwise
7 rotate 90 degree anticlockwise and mirror horizontally
8 rotate 90 degree anticlockwise


colorModel

public java.awt.image.ColorModel colorModel
Current Java style ColorModel


bytePixels

public byte[] bytePixels
Array of bytes containing image data (if palette image with more than 16 colors)


intPixels

public int[] intPixels
Array of integers containing image data (if truecolor image)


packedPixels

public byte[] packedPixels
Array of bytes containing packed image data (if palette image with 16 or less colors)


errorMsg

public java.lang.String errorMsg
Error message of last operation


jpegDecodeParam

public com.sun.image.codec.jpeg.JPEGDecodeParam jpegDecodeParam
Constructor Detail

ImageInfo

public ImageInfo()
Constructor for ImageInfo

Method Detail

detectImageFormat

public void detectImageFormat()
Method to detect image format from file extension


setDefaults

public void setDefaults()
Set default values for important image info variables


getAnnotations

public void getAnnotations()
Load annotation file (expected with same name like imgName or imgUrl but with extension ".xml").


createImageProducer

public void createImageProducer()
                         throws java.awt.AWTException
Create an image producer from imgName or imgUrl. Requires that Toolkit was set before (using method setAsynchronousTools())

Throws:
java.awt.AWTException

run

public void run()
Allows to run the creation of an image producer asynchronously as seperate thread. Requires that Toolkit was set before (use method setAsynchronousTools())

Specified by:
run in interface java.lang.Runnable

setAsynchronousTools

public void setAsynchronousTools(java.awt.Toolkit toolkit,
                                 ImgProdObserver imgProdObserver,
                                 boolean asyncMode)
Define all necessary parameters to be able to start image production as an asynchronous thread afterwards.

Parameters:
toolkit - is the Toolkit provided by AWT classes
imgProdObserver - used during asynchronous loading to inform the observing class when loading is finished.

calcPixelSize

public int calcPixelSize()
calulate real number of bits per pixel according to mapSize of ColorModel Note: ColorModel.getPixelSize() usually reports 8 even if mapsize < 256 (especially required for JDK 1.2)

Returns:
(packed) bits per pixel according to mapSize of ColorModel

toString

public java.lang.String toString()
Returns information about the image