O2Plib.image
Class PixReader

java.lang.Object
  extended by O2Plib.image.PixReader

public class PixReader
extends java.lang.Object


Nested Class Summary
(package private)  class PixReader.PixObserver
          PixObserver implements our own (rather than default) image observer
 
Field Summary
 byte[] bytePix
          8-bits/pixel image if it exists
 char[] charPix
          16-bits/pixel image if it exists.
 boolean dbugFlag
          To track additional loading info
 boolean errorLoadingImageFlag
          set after image loaded
 java.awt.Image image
          image instance
 java.lang.String imgFile
          full file path name of the input image
 java.lang.String imgType
          image type: "TIFF", "JPG", "GIF", "PPX"
 int[] intPix
          16-bits/pixel image if it exists packed in LSB of 232-bit int Data may be 8-bits to 16/bits/pixel
static boolean isColorImageFlag
          The image was a RGB color image converted to grayscale using the NTSC color transform.
 boolean isLoadedFlag
          set after image loaded
 int maxGrayPixel
          maxGrayPixel pixel value in the image
 int minGrayPixel
          minGrayPixel pixel value in the image
 int nBitsPerPixel
          # of bits/pixel in the image
 int nBytesPerPixel
          # of bytes/pixel in the image
 int nCols
          # of columns in the image
private static boolean NEVER
          Debugging
 int nPixels
          # of columns X # rows in the image
 int nRows
          # of rows in the image
static int nth
          dump sequantially named pictures using numbered image files
static java.lang.String VERSION
          Version for this module
 
Constructor Summary
PixReader()
          PixReader() - Constructor to use when reading an image file
PixReader(int[] intPix)
          PixReader() - Constructor to use when converting an int[] pix to a char[] pixel array using getCharPix().
PixReader(java.lang.String imgFileName)
          PixReader() - init the state of the image reader
 
Method Summary
 void clearImageReader(java.lang.String imgFileName)
          clearImageReader() - init the state of the image reader
 char[] getCharPix()
          getCharPix() - map the image to char[].
private static byte[] getPixelDataFromImage(java.awt.Image img, int width, int height)
          getPixelDataFromImage() - get the pixel data from the image
 boolean loadGifOrJpegPix(java.lang.String imageFile)
          loadGifOrJpegPix() - read GIF or JPEG pix file into this obj as bytePix[] and return as intPix[].
 boolean loadJpeg2000Pix(java.lang.String imageFile)
          loadJpeg2000Pix() - read JPEG2000 pix file into this obj as either charPix[] or bytePix[] depending on whether it is > 8-bits/pixel or not.
 boolean loadPPXpix(java.lang.String imageFile)
          loadPPXpix() - read GELLAB-II PPX pix file into this obj as bytePix[] and return as int{ox[].
 boolean loadTiffPix(java.lang.String imageFile)
          loadTiffPix() - read Tiff pix file into this obj as a grayscale intPix[].
 PixReader readImageFile(java.lang.String imgFile)
          readImageFile() - read an image fileread new image file.
 void setDebugFlag(boolean dbugFlag)
          setDebugFlag() - flag to track additional loading info
private  java.lang.String showMediaTrackerStatusBits(java.lang.String msg, java.net.URL imageURL, java.lang.String imageFile, java.awt.MediaTracker tracker)
          showMediaTrackerStatusBits() - print the media tracker status bits
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
Version for this module

See Also:
Constant Field Values

NEVER

private static final boolean NEVER
Debugging

See Also:
Constant Field Values

nth

public static int nth
dump sequantially named pictures using numbered image files


dbugFlag

public boolean dbugFlag
To track additional loading info


isLoadedFlag

public boolean isLoadedFlag
set after image loaded


errorLoadingImageFlag

public boolean errorLoadingImageFlag
set after image loaded


image

public java.awt.Image image
image instance


isColorImageFlag

public static boolean isColorImageFlag
The image was a RGB color image converted to grayscale using the NTSC color transform.


imgFile

public java.lang.String imgFile
full file path name of the input image


imgType

public java.lang.String imgType
image type: "TIFF", "JPG", "GIF", "PPX"


nRows

public int nRows
# of rows in the image


nCols

public int nCols
# of columns in the image


nPixels

public int nPixels
# of columns X # rows in the image


nBytesPerPixel

public int nBytesPerPixel
# of bytes/pixel in the image


nBitsPerPixel

public int nBitsPerPixel
# of bits/pixel in the image


minGrayPixel

public int minGrayPixel
minGrayPixel pixel value in the image


maxGrayPixel

public int maxGrayPixel
maxGrayPixel pixel value in the image


bytePix

public byte[] bytePix
8-bits/pixel image if it exists


charPix

public char[] charPix
16-bits/pixel image if it exists. Data may be 9-bits to 16/bits/pixel


intPix

public int[] intPix
16-bits/pixel image if it exists packed in LSB of 232-bit int Data may be 8-bits to 16/bits/pixel

Constructor Detail

PixReader

public PixReader()
PixReader() - Constructor to use when reading an image file


PixReader

public PixReader(int[] intPix)
PixReader() - Constructor to use when converting an int[] pix to a char[] pixel array using getCharPix().

Parameters:
intPix - is integer array
See Also:
getCharPix()

PixReader

public PixReader(java.lang.String imgFileName)
PixReader() - init the state of the image reader

Parameters:
imgFileName - image that will be reading
Method Detail

clearImageReader

public void clearImageReader(java.lang.String imgFileName)
clearImageReader() - init the state of the image reader

Parameters:
imgFileName - image that will be reading

setDebugFlag

public void setDebugFlag(boolean dbugFlag)
setDebugFlag() - flag to track additional loading info

Parameters:
dbugFlag - - debug flag status

readImageFile

public PixReader readImageFile(java.lang.String imgFile)
readImageFile() - read an image fileread new image file.

Parameters:
imgFile - is the full path of the image to read
Returns:
null if there is a problem, else return a new PixReader instance with the image size, depth, and data are available.

getCharPix

public char[] getCharPix()
getCharPix() - map the image to char[]. If charPix exists then use it, else if intPix exists, convert it to charPix and G.C. intPix.

Returns:
char[] image, null if any errors.

loadTiffPix

public boolean loadTiffPix(java.lang.String imageFile)
loadTiffPix() - read Tiff pix file into this obj as a grayscale intPix[].

Parameters:
imageFile - image file name
Returns:
true if succeed

loadPPXpix

public boolean loadPPXpix(java.lang.String imageFile)
loadPPXpix() - read GELLAB-II PPX pix file into this obj as bytePix[] and return as int{ox[].

Parameters:
imageFile - image file name
Returns:
true if succeed

loadGifOrJpegPix

public boolean loadGifOrJpegPix(java.lang.String imageFile)
loadGifOrJpegPix() - read GIF or JPEG pix file into this obj as bytePix[] and return as intPix[].

Parameters:
imageFile - image file name
Returns:
true if succeed

loadJpeg2000Pix

public boolean loadJpeg2000Pix(java.lang.String imageFile)
loadJpeg2000Pix() - read JPEG2000 pix file into this obj as either charPix[] or bytePix[] depending on whether it is > 8-bits/pixel or not. This will then get mapped to the intPix[] used by Open2Dprot. [TODO]

Parameters:
imageFile - image file name
Returns:
true if succeed

getPixelDataFromImage

private static byte[] getPixelDataFromImage(java.awt.Image img,
                                            int width,
                                            int height)
getPixelDataFromImage() - get the pixel data from the image

Parameters:
img - image to use
width - of image
height - of image
Returns:
byte[] array of pixel data,

showMediaTrackerStatusBits

private java.lang.String showMediaTrackerStatusBits(java.lang.String msg,
                                                    java.net.URL imageURL,
                                                    java.lang.String imageFile,
                                                    java.awt.MediaTracker tracker)
showMediaTrackerStatusBits() - print the media tracker status bits

Parameters:
msg - to add prefix to status string
imageURL -
imageFile -
tracker - MediaTracker being used
Returns:
status string