|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jj2000.j2k.image.output.ImgWriter | +--jj2000.j2k.image.output.ImgWriterPGM
This class writes a component from an image in 8 bit unsigned data to a binary PGM file. The size of the image that is written to the file is the size of the component from which to get the data, not the size of the source image (they differ if there is some sub-sampling).
Before writing, all coefficients are inversly level shifted and then
"saturated" (they are limited to the nominal dynamic range).
Ex:
if the nominal range is 0-255, the following algorithm is applied:
if coeff<0, output=0
if coeff>255, output=255
else
output=coeff
The write() methods of an object of this class may not be called concurrently from different threads.
NOTE: This class is not thread safe, for reasons of internal buffering.
Field Summary | |
private byte[] |
buf
The line buffer. |
private int |
c
The index of the component from where to get the data |
private DataBlkInt |
db
A DataBlk, just used to avoid allocating a new one each time it is needed |
private int |
fb
The number of fractional bits in the source data |
private int |
levShift
Value used to inverse level shift |
private int |
offset
The offset of the raw pixel data in the PGM file |
private java.io.RandomAccessFile |
out
Where to write the data |
Fields inherited from class jj2000.j2k.image.output.ImgWriter |
DEF_STRIP_HEIGHT, h, src, w |
Constructor Summary | |
ImgWriterPGM(java.io.File out,
BlkImgDataSrc imgSrc,
int c)
Creates a new writer to the specified File object, to write data from the specified component. |
|
ImgWriterPGM(java.lang.String fname,
BlkImgDataSrc imgSrc,
int c)
Creates a new writer to the specified file, 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. |
java.lang.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. |
private void |
writeHeaderInfo()
Writes the header info of the PGM file : P5 width height 255 |
Methods inherited from class jj2000.j2k.image.output.ImgWriter |
finalize, writeAll |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private int levShift
private java.io.RandomAccessFile out
private int c
private int fb
private DataBlkInt db
private int offset
private byte[] buf
Constructor Detail |
public ImgWriterPGM(java.io.File out, BlkImgDataSrc imgSrc, int c) throws java.io.IOException
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).
out
- The file where to write the dataimgSrc
- The source from where to get the image data to write.c
- The index of the component from where to get the data.public ImgWriterPGM(java.lang.String fname, BlkImgDataSrc imgSrc, int c) throws java.io.IOException
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).
fname
- The name of the file where to write the dataimgSrc
- The source from where to get the image data to write.c
- The index of the component from where to get the data.Method Detail |
public void close() throws java.io.IOException
close
in class ImgWriter
java.io.IOException
- If an I/O error occurs.public void flush() throws java.io.IOException
flush
in class ImgWriter
java.io.IOException
- If an I/O error occurs.public void write(int ulx, int uly, int w, int h) throws java.io.IOException
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.
write
in class ImgWriter
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.
java.io.IOException
- If an I/O error occurs.public void write() throws java.io.IOException
If the data returned from the BlkImgDataSrc source is progressive, then it is requested over and over until it is not progressive anymore.
write
in class ImgWriter
java.io.IOException
- If an I/O error occurs.DataBlk
private void writeHeaderInfo() throws java.io.IOException
java.io.IOException
- If there is an IOExceptionpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |