jj2000.j2k.image.output
Class ImgWriter

java.lang.Object
  |
  +--jj2000.j2k.image.output.ImgWriter
Direct Known Subclasses:
ImgWriterPGM, ImgWriterPGX, ImgWriterPPM

public abstract class ImgWriter
extends java.lang.Object

This is the generic interface to be implemented by all image file (or other resource) writers for different formats.

Each object inheriting from this class should have a source ImgData object associated with it. The image data to write to the file is obtained from the associated ImgData object. In general this object would be specified at construction time.

Depending on the actual type of file that is written a call to any write() or writeAll() method will write data from one component, several components or all components. For example, a PGM writer will write data from only one component (defined in the constructor) while a PPM writer will write 3 components (normally R,G,B).


Field Summary
static int DEF_STRIP_HEIGHT
          The defaukt height used when writing strip by strip in the 'write()' method.
protected  int h
          The height of the image
protected  BlkImgDataSrc src
          The source ImagaData object, from where to get the image data
protected  int w
          The width of the image
 
Constructor Summary
ImgWriter()
           
 
Method Summary
abstract  void close()
          Closes the underlying file or netwrok connection to where the data is written.
 void finalize()
          Flushes the buffered data before the object is garbage collected.
abstract  void flush()
          Writes all buffered data to the file or resource.
abstract  void write()
          Writes the source's current tile to the output.
abstract  void write(int ulx, int uly, int w, int h)
          Writes the data of the specified area to the file, coordinates are relative to the current tile of the source.
 void writeAll()
          Writes the entire image or only specified tiles to the output.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEF_STRIP_HEIGHT

public static final int DEF_STRIP_HEIGHT
The defaukt height used when writing strip by strip in the 'write()' method. It is 64.

See Also:
Constant Field Values

src

protected BlkImgDataSrc src
The source ImagaData object, from where to get the image data


w

protected int w
The width of the image


h

protected int h
The height of the image

Constructor Detail

ImgWriter

public ImgWriter()
Method Detail

close

public abstract void close()
                    throws java.io.IOException
Closes the underlying file or netwrok connection to where the data is written. The implementing class must write all buffered data before closing the file or resource. Any call to other methods of the class become illegal after a call to this one.

Throws:
java.io.IOException - If an I/O error occurs.

flush

public abstract void flush()
                    throws java.io.IOException
Writes all buffered data to the file or resource. If the implementing class does onot use buffering nothing should be done.

Throws:
java.io.IOException - If an I/O error occurs.

finalize

public void finalize()
              throws java.io.IOException
Flushes the buffered data before the object is garbage collected. If an exception is thrown the object finalization is halted, but is otherwise ignored.

Overrides:
finalize in class java.lang.Object
Throws:
java.io.IOException - If an I/O error occurs. It halts the finalization of the object, but is otherwise ignored.
See Also:
Object.finalize()

write

public abstract void write()
                    throws java.io.IOException
Writes the source's current tile to the output. The requests of data issued by the implementing class to the source ImgData object should be done by blocks or strips, in order to reduce memory usage.

The implementing class should only write data that is not "progressive" (in other words that it is final), see DataBlk for details.

Throws:
java.io.IOException - If an I/O error occurs.
See Also:
DataBlk

writeAll

public void writeAll()
              throws java.io.IOException
Writes the entire image or only specified tiles to the output. The implementation in this class calls the write() method for each tile starting with the upper-left one and proceding in standard scanline order. It changes the current tile of the source data.

Throws:
java.io.IOException - If an I/O error occurs.
See Also:
DataBlk

write

public abstract void write(int ulx,
                           int uly,
                           int w,
                           int h)
                    throws java.io.IOException
Writes the data of the specified area to the file, coordinates are relative to the current tile of the source.

The implementing class should only write data that is not "progressive" (in other words that is final), see DataBlk for details.

Parameters:
ulx - The horizontal coordinate of the upper-left corner of the area to write, relative to the current tile.
uly - The vertical coordinate of the upper-left corner of the area to write, relative to the current tile.
Throws:
java.io.IOException - If an I/O error occurs.