ucar.jpeg.jj2000.j2k.image.output
Class ImgWriterArray

java.lang.Object
  extended by ucar.jpeg.jj2000.j2k.image.output.ImgWriter
      extended by ucar.jpeg.jj2000.j2k.image.output.ImgWriterArray

public class ImgWriterArray
extends ImgWriter

This class extends the ImgWriter abstract class for writing Array . Data: The image binary values appear one after the other (in raster order) immediately after the last header character ('\n') and are byte-aligned (they are packed into 1,2 or 4 bytes per sample, depending upon the bit-depth value).

If the data is unsigned, level shifting is applied adding 2^(bit depth - 1)

NOTE: This class is not thread safe, for reasons of internal buffering.

See Also:
ImgWriter, BlkImgDataSrc

Field Summary
 
Fields inherited from class ucar.jpeg.jj2000.j2k.image.output.ImgWriter
DEF_STRIP_HEIGHT, h, src, w
 
Constructor Summary
ImgWriterArray(BlkImgDataSrc imgSrc, int c, boolean isSigned)
          Creates a new writer to the specified Array object, to write data from the specified component.
 
Method Summary
 void close()
          Closes the underlying file or netwrok connection to where the data is written.
 void flush()
          Writes all buffered data to the file or resource.
 int[] getGdata()
          the jpeg data decoded into a array
 int getPackBytes()
          The pack length of one sample (in bytes, according to the output bit-depth
 String toString()
          Returns a string of information about the object, more than 1 line long.
 void write()
          Writes the source's current tile to the output.
 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 ucar.jpeg.jj2000.j2k.image.output.ImgWriter
finalize
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ImgWriterArray

public ImgWriterArray(BlkImgDataSrc imgSrc,
                      int c,
                      boolean isSigned)
               throws IOException
Creates a new writer to the specified Array object, to write data from the specified component.

The size of the image that is written to the file is the size of the component from which to get the data, specified by b, not the size of the source image (they differ if there is some sub-sampling).

Parameters:
imgSrc - The source from where to get the image data to write.
c - The index of the component from where to get the data.
isSigned - Whether the datas are signed or not (needed only when writing header).
Throws:
IOException
See Also:
DataBlk
Method Detail

close

public void close()
           throws IOException
Closes the underlying file or netwrok connection to where the data is written. Any call to other methods of the class become illegal after a call to this one.

Specified by:
close in class ImgWriter
Throws:
IOException - If an I/O error occurs.

write

public void write(int ulx,
                  int uly,
                  int w,
                  int h)
           throws IOException
Writes the data of the specified area to the file, coordinates are relative to the current tile of the source. Before writing, the coefficients are limited to the nominal range and packed into 1,2 or 4 bytes (according to the bit-depth).

If the data is unisigned, level shifting is applied adding 2^(bit depth - 1)

This method may not be called concurrently from different threads.

If the data returned from the BlkImgDataSrc source is progressive, then it is requested over and over until it is not progressive anymore.

Specified by:
write in class ImgWriter
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.
width - The width of the area to write.
height - The height of the area to write.
Throws:
IOException - If an I/O error occurs.

writeAll

public void writeAll()
              throws IOException
Description copied from class: ImgWriter
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.

Overrides:
writeAll in class ImgWriter
Throws:
IOException - If an I/O error occurs.
See Also:
DataBlk

write

public void write()
           throws IOException
Writes the source's current tile to the output. The requests of data issued to the source BlkImgDataSrc object are done by strips, in order to reduce memory usage.

If the data returned from the BlkImgDataSrc source is progressive, then it is requested over and over until it is not progressive anymore.

Specified by:
write in class ImgWriter
Throws:
IOException - If an I/O error occurs.
See Also:
DataBlk

getPackBytes

public int getPackBytes()
The pack length of one sample (in bytes, according to the output bit-depth


getGdata

public int[] getGdata()
the jpeg data decoded into a array

Returns:
a byte[]

flush

public void flush()
Description copied from class: ImgWriter
Writes all buffered data to the file or resource. If the implementing class does onot use buffering nothing should be done.

Specified by:
flush in class ImgWriter

toString

public String toString()
Returns a string of information about the object, more than 1 line long. The information string includes information from the underlying RandomAccessFile (its toString() method is called in turn).

Overrides:
toString in class Object
Returns:
A string of information about the object.


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.