Class ImageIO

java.lang.Object
  extended by ImageIO

public class ImageIO
extends java.lang.Object

ImageIO class is used to do Flicker image I/O and conversion functions.

This work was produced by Peter Lemkin of the National Cancer Institute, an agency of the United States Government. As a work of the United States Government there is no associated copyright. It is offered as open source software under the Mozilla Public License (version 1.1) subject to the limitations noted in the accompanying LEGAL file. This notice must be included with the code. The Flicker Mozilla and Legal files are available on http://open2dprot.sourceforge.net/Flicker

Version:
$Date$ $Revision$
Author:
P. Lemkin (LECB/NCI), G. Thornwall (SAIC), Frederick, MD, USA
See Also:
Flicker Home

Field Summary
private  BuildGUI bGui
          BuildGUI instance
static int count
          counter to print '.' every NLINES lines
 Flicker flk
          Flicker class
 boolean isLoadedFlag
          set after loaded
static java.lang.String[] legalImageFileExtensions
          list of legal image file extensions
static int NLINES
          # of lines to read before update status
(package private)  java.lang.String sWorking
          for incremental loading message progress string
private  Util util
          extended Flicker state variable class
 
Constructor Summary
ImageIO(Flicker flk, java.lang.String sWorking)
          ImageIO() - Constructor
 
Method Summary
 boolean changeImageFromSpec(java.lang.String newImageFileStr, java.lang.String leftRightStr, boolean initSliderStateFlag, boolean reportErrorMsgsFlag)
          changeImageFromSpec() - load a new image from file.
static boolean flushImageResources(java.awt.Image img)
          flushImageResources() - flush image resources of no-longer needed image.
 java.lang.String get_sWorking()
          get_sWorking() - get the working image progress string
 ImageData loadGifOrJpegPixIntoImageData(java.lang.String imageFile, ImageData oldImageData, int imgNbr, boolean reportErrorMsgsFlag)
          loadGifOrJpegPixIntoImageData() - read GIF or JPEG pix file into ImageData object which includes an iPix[] of the data.
 ImageData loadJpeg2000PixIntoImageData(java.lang.String imageFile, ImageData oldImageData, int imgNbr, boolean reportErrorMsgsFlag)
          loadJpeg2000PixIntoImageData() - read JPEG 2000 pix file into ImageData object which includes a iPix[] of the data.
 ImageData loadPixIntoImageData(java.lang.String imageFile, ImageData oldImageData, int imgNbr, boolean reportErrorMsgsFlag)
          loadPixIntoImageData() - read pix file into ImageData obj.
 ImageData loadPPXpixIntoImageData(java.lang.String imageFile, ImageData oldImageData, int imgNbr, boolean reportErrorMsgsFlag)
          loadPPXpixIntoImageData() - read GELLAB-II PPX pix file into ImageData object which includes a iPix[] of the data.
 ImageData loadTiffPixIntoImageData(java.lang.String imageFile, ImageData oldImageData, int imgNbr, boolean reportErrorMsgsFlag)
          loadTiffPixIntoImageData() - read Tiff pix file into ImageData object which includes a iPix[] of the data.
 void restoreImage(ImageData iDataR, boolean reportErrorMsgsFlag)
          restoreImage() - restore images from original copy (iPix) that was first read in.
 void set_sWorking(java.lang.String s)
          set_sWorking() - set the working image progress string
 ImageData setImageToImageData(java.lang.String imageFile, java.awt.Image iImg, boolean blackIsZeroFlag, ImageData imgData, float[] mapGraytoOD, int imgNbr)
          setImageToImageData() - set the Image and associated parameters to the ImageData object imgData.
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

flk

public Flicker flk
Flicker class


bGui

private BuildGUI bGui
BuildGUI instance


util

private Util util
extended Flicker state variable class


legalImageFileExtensions

public static final java.lang.String[] legalImageFileExtensions
list of legal image file extensions


isLoadedFlag

public boolean isLoadedFlag
set after loaded


NLINES

public static final int NLINES
# of lines to read before update status

See Also:
Constant Field Values

count

public static int count
counter to print '.' every NLINES lines


sWorking

java.lang.String sWorking
for incremental loading message progress string

Constructor Detail

ImageIO

public ImageIO(Flicker flk,
               java.lang.String sWorking)
ImageIO() - Constructor

Method Detail

get_sWorking

public java.lang.String get_sWorking()
get_sWorking() - get the working image progress string


set_sWorking

public void set_sWorking(java.lang.String s)
set_sWorking() - set the working image progress string


loadPixIntoImageData

public ImageData loadPixIntoImageData(java.lang.String imageFile,
                                      ImageData oldImageData,
                                      int imgNbr,
                                      boolean reportErrorMsgsFlag)
loadPixIntoImageData() - read pix file into ImageData obj. which includes a iPix[] of the data. If overloading a new image into an existing ImageData structure then specify the oldImageData structure else set it to null. If the file is used standalone with imageURL set to null, then it assumes it will be "file://localhost/" + imageFile or "file://localhost" + imageFile This is done using the constructor: URL(protocol, host, filename) where protocol= "file" host= "localhost". Note: if DOS file system "C:\pixfile.gif", then remap to "file://localhost/C:\pixfile.gif"

Parameters:
imageURL - url for the image file
imageFile - image file name
oldImageData - is old ImageData
imgNbr - for debugging
reportErrorMsgsFlag - to report error it it occurs on load
Returns:
ImageData for the picture else null if a problem.

loadTiffPixIntoImageData

public ImageData loadTiffPixIntoImageData(java.lang.String imageFile,
                                          ImageData oldImageData,
                                          int imgNbr,
                                          boolean reportErrorMsgsFlag)
loadTiffPixIntoImageData() - read Tiff pix file into ImageData object which includes a iPix[] of the data. If overloading a new image into an existing ImageData structure then specify the oldImageData structure else set it to null.

Parameters:
imageURL - url for the image file
imageFile - image file name
oldImageData - is old ImageData
imgNbr - for debugging
reportErrorMsgsFlag - to report error it it occurs on load
Returns:
ImageData for the picture else null if a problem.

loadPPXpixIntoImageData

public ImageData loadPPXpixIntoImageData(java.lang.String imageFile,
                                         ImageData oldImageData,
                                         int imgNbr,
                                         boolean reportErrorMsgsFlag)
loadPPXpixIntoImageData() - read GELLAB-II PPX pix file into ImageData object which includes a iPix[] of the data. If overloading a new image into an existing ImageData structure then specify the oldImageData structure else set it to null.

Parameters:
imageURL - url for the image file
imageFile - image file name
oldImageData - is old ImageData
imgNbr - for debugging
reportErrorMsgsFlag - to report error it it occurs on load
Returns:
ImageData for the picture else null if a problem.

loadJpeg2000PixIntoImageData

public ImageData loadJpeg2000PixIntoImageData(java.lang.String imageFile,
                                              ImageData oldImageData,
                                              int imgNbr,
                                              boolean reportErrorMsgsFlag)
loadJpeg2000PixIntoImageData() - read JPEG 2000 pix file into ImageData object which includes a iPix[] of the data. If overloading a new image into an existing ImageData structure then specify the oldImageData structure else set it to null. [TODO] need to integrate a JPEG 2000 Java reader. Could possibly use JJ2000 at http://jj2000.epfl.ch/

Parameters:
imageURL - url for the image file
imageFile - image file name
oldImageData - is old ImageData
imgNbr - for debugging
reportErrorMsgsFlag - to report error it it occurs on load
Returns:
ImageData for the picture else null if a problem.

loadGifOrJpegPixIntoImageData

public ImageData loadGifOrJpegPixIntoImageData(java.lang.String imageFile,
                                               ImageData oldImageData,
                                               int imgNbr,
                                               boolean reportErrorMsgsFlag)
loadGifOrJpegPixIntoImageData() - read GIF or JPEG pix file into ImageData object which includes an iPix[] of the data. If overloading a new image into an existing ImageData structure then specify the oldImageData structure else set it to null. If the file is used standalone with imageURL set to null, then it assumes it will be "file://localhost/" + imageFile or "file://localhost" + imageFile This is done using the constructor: URL(protocol, host, filename) where protocol= "file" host= "localhost". Note: if DOS file system "C:\pixfile.gif", then remap to "file://localhost/C:\pixfile.gif"

Parameters:
imageURL - url for the image file
imageFile - image file name
oldImageData - is old ImageData
imgNbr - for debugging
reportErrorMsgsFlag - to report error it it occurs on load
Returns:
ImageData for the picture else null if a problem.

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

setImageToImageData

public ImageData setImageToImageData(java.lang.String imageFile,
                                     java.awt.Image iImg,
                                     boolean blackIsZeroFlag,
                                     ImageData imgData,
                                     float[] mapGraytoOD,
                                     int imgNbr)
setImageToImageData() - set the Image and associated parameters to the ImageData object imgData. If imgData does not exist (i.e. null), then create a new ImageData object.

Parameters:
imageFile - image file name
iImg - image just read
blackIsZeroFlag - is true if image has black as 0 gray value
imgData - is old ImageData object if it exists
mapGrayToOD - is Map of Gray to OD if exists and is not null
imgNbr - for debugging
Returns:
ImageData is returned, null if error.

changeImageFromSpec

public boolean changeImageFromSpec(java.lang.String newImageFileStr,
                                   java.lang.String leftRightStr,
                                   boolean initSliderStateFlag,
                                   boolean reportErrorMsgsFlag)
changeImageFromSpec() - load a new image from file. leftRightStr should be either "left" (i.e. iData1) import "right" (i.e., iData2). At that point we can create an image from the input iPix data and repaint it.

Parameters:
newImageFileStr - is either URL string or File path
leftRightStr - is "left" or "right" image indicator
initSliderStateFlag - to init the slider state
reportErrorMsgsFlag - to report error it it occurs on load
Returns:
true if succeed

restoreImage

public void restoreImage(ImageData iDataR,
                         boolean reportErrorMsgsFlag)
restoreImage() - restore images from original copy (iPix) that was first read in. This deletes the oImg and bgImg so that it displays the original image. It does NOT restore the various parameters. [TODO] there are some conditions where it may not restore correctly. We need to document these conditions and fix it.

Parameters:
reportErrorMsgsFlag - to report error it it occurs on load
iDataR - is the image to restore. It should be either flk.iData1 or flk.iData2

flushImageResources

public static boolean flushImageResources(java.awt.Image img)
flushImageResources() - flush image resources of no-longer needed image. Do this before garbage collect memory before create additional data See Chen&Lee Vol 2, pg 801-802 for freeing resources

Parameters:
img - is the image to flush
Returns:
true if image was flushed.