|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jj2000.j2k.image.output.ImgWriter | +--jj2000.j2k.image.output.ImgWriterPGX
This class extends the ImgWriter abstract class for writing PGX files. PGX is a custom monochrome file format invented specifically to simplify the use of VM3A with images of different bit-depths in the range 1 to 31 bits per pixel.
The file consists of a one line text header followed by the binary datas.
Header:
"PG"+ ws +<endianess>+ ws +[sign]+
ws + <bit-depth>+" "+<width>+" "+
<height>+'\n'
where:
- ws(white-spaces) is any combination of characters ' ' and
'\t'.
- endianess equals "LM" or "ML"(resp. little-endian
or big-endian).
- sign equals "+" or "-" (resp. unsigned or signed). If ommited,
default value is unsigned.
- bit-depth can be any number between 1 and 31.
- width and height are the image dimensions (in pixels).
Datas:
The image binary datas appear one after the other(in raster order)
immediatly 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.
ImgWriter
,
BlkImgDataSrc
Field Summary | |
private int |
bitDepth
The bit-depth of the input file (must be between 1 and 31) |
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 |
(package private) boolean |
isSigned
Whether the data must be signed when writing or not. |
(package private) int |
levShift
Used with level-shiting |
(package private) int |
maxVal
Used during saturation (2^bitdepth-1 if unsigned, 2^(bitdepth-1)-1 if signed) |
(package private) int |
minVal
Used during saturation (0 if unsigned, -2^(bitdepth-1) if signed) |
private int |
offset
The offset of the raw pixel data in the PGX file |
private java.io.RandomAccessFile |
out
Where to write the data |
private int |
packBytes
The pack length of one sample (in bytes, according to the output bit-depth |
Fields inherited from class jj2000.j2k.image.output.ImgWriter |
DEF_STRIP_HEIGHT,
h,
src,
w |
Constructor Summary | |
ImgWriterPGX(java.io.File out,
BlkImgDataSrc imgSrc,
int n,
boolean isSigned)
Creates a new writer to the specified File object, to write data from the specified component. |
|
ImgWriterPGX(java.lang.String fname,
BlkImgDataSrc imgSrc,
int n,
boolean isSigned)
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. |
Methods inherited from class jj2000.j2k.image.output.ImgWriter |
finalize,
writeAll |
Methods inherited from class java.lang.Object |
|
Field Detail |
int maxVal
int minVal
int levShift
boolean isSigned
private int bitDepth
private java.io.RandomAccessFile out
private int offset
private DataBlkInt db
private int fb
private int c
private int packBytes
private byte[] buf
Constructor Detail |
public ImgWriterPGX(java.io.File out, BlkImgDataSrc imgSrc, int n, boolean isSigned) 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).
All the header informations are given by the BlkImgDataSrc source (component width, component height, bit-depth) and sign flag, which are provided to the constructor. The endianness is always big-endian (MSB first).
out
- The file where to write the dataimgSrc
- The source from where to get the image data to
write.n
- The index of the component from where to get the data.isSigned
- Whether the datas are signed or not (needed only
when writing header).DataBlk
public ImgWriterPGX(java.lang.String fname, BlkImgDataSrc imgSrc, int n, boolean isSigned) 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).
All the header informations are given by the BlkImgDataSrc source (component width, component height, bit-depth) and sign flag, which are provided to the constructor. The endianness is always big-endian (MSB first).
fname
- The name of the file where to write the dataimgSrc
- The source from where to get the image data to
write.n
- The index of the component from where to get the data.isSigned
- Whether the datas are signed or not (needed only
when writing header).DataBlk
Method Detail |
public void close() throws java.io.IOException
public void flush() throws java.io.IOException
public void write(int ulx, int uly, int w, int h) throws java.io.IOException
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.
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.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.
DataBlk
public java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |