Class ImgWriterRAW
- Direct Known Subclasses:
ImgWriterRAWColor
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe bit-depth of the input file (must be between 1 and 31)private byte[]The line buffer.protected intThe index of the component from where to get the dataprotected jj2000.j2k.image.DataBlkIntA DataBlk, just used to avoid allocating a new one each time it is neededprivate intThe number of fractional bits in the source dataprotected int(package private) booleanWhether the data must be signed when writing or not.(package private) intUsed with level-shifting(package private) intUsed during saturation (2^bitdepth-1 if unsigned, 2^(bitdepth-1)-1 if signed)(package private) intUsed during saturation (0 if unsigned, -2^(bitdepth-1) if signed)protected ModelImageModel image pointerprotected intThe current offset of the raw pixel data in the RAW fileprotected intThe number of layers/componentsprotected intThe current offset of the raw pixel data in the RAW fileprivate RandomAccessFileWhere to write the dataprotected intThe pack length of one sample (in bytes, according to the output bit-depthFields inherited from class jj2000.j2k.image.output.ImgWriter
DEF_STRIP_HEIGHT, h, src, w -
Constructor Summary
ConstructorsConstructorDescriptionImgWriterRAW(ModelImage mi, jj2000.j2k.image.BlkImgDataSrc imgSrc, boolean isSigned) ImgWriterRAW(File out, jj2000.j2k.image.BlkImgDataSrc imgSrc, int c, boolean isSigned) Creates a new writer to the specified File object, to write data from the specified component.ImgWriterRAW(String fname, jj2000.j2k.image.BlkImgDataSrc imgSrc, int c, boolean isSigned) Creates a new writer to the specified file, to write data from the specified component. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the underlying file or netwrok connection to where the data is written.voidflush()Writes all buffered data to the file or resource.intintvoidsetImgType(int imgType) voidsetOffset(int slcIdx) voidsetSrc(jj2000.j2k.image.BlkImgDataSrc slc) toString()Returns a string of information about the object, more than 1 line long.voidwrite()Writes the source's current tile to the output.voidwrite(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.voidvoidMethods inherited from class jj2000.j2k.image.output.ImgWriter
finalize, writeAll
-
Field Details
-
maxVal
int maxValUsed during saturation (2^bitdepth-1 if unsigned, 2^(bitdepth-1)-1 if signed) -
minVal
int minValUsed during saturation (0 if unsigned, -2^(bitdepth-1) if signed) -
levShift
int levShiftUsed with level-shifting -
isSigned
boolean isSignedWhether the data must be signed when writing or not. In the latter case inverse level shifting must be applied -
bitDepth
protected int bitDepthThe bit-depth of the input file (must be between 1 and 31) -
out
Where to write the data -
offset
protected int offsetThe current offset of the raw pixel data in the RAW file -
modImgOffset
protected int modImgOffsetThe current offset of the raw pixel data in the RAW file -
db
protected jj2000.j2k.image.DataBlkInt dbA DataBlk, just used to avoid allocating a new one each time it is needed -
fb
private int fbThe number of fractional bits in the source data -
c
protected int cThe index of the component from where to get the data -
nc
protected int ncThe number of layers/components -
packBytes
protected int packBytesThe pack length of one sample (in bytes, according to the output bit-depth -
buf
private byte[] bufThe line buffer. -
modImg
Model image pointer -
imgType
protected int imgType
-
-
Constructor Details
-
ImgWriterRAW
public ImgWriterRAW(File out, jj2000.j2k.image.BlkImgDataSrc imgSrc, int c, boolean isSigned) throws IOException Creates a new writer to the specified File 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).
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).
- Parameters:
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.isSigned- Whether the datas are signed or not (needed only when writing header).- Throws:
IOException- See Also:
-
ImgWriterRAW
public ImgWriterRAW(ModelImage mi, jj2000.j2k.image.BlkImgDataSrc imgSrc, boolean isSigned) throws IOException - Throws:
IOException
-
ImgWriterRAW
public ImgWriterRAW(String fname, jj2000.j2k.image.BlkImgDataSrc imgSrc, int c, boolean isSigned) throws IOException Creates a new writer to the specified file, 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).
All header information is 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).
- Parameters:
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.isSigned- Whether the datas are signed or not (needed only when writing header).- Throws:
IOException- See Also:
-
-
Method Details
-
close
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:
closein classjj2000.j2k.image.output.ImgWriter- Throws:
IOException- If an I/O error occurs.
-
flush
Writes all buffered data to the file or resource.- Specified by:
flushin classjj2000.j2k.image.output.ImgWriter- Throws:
IOException- If an I/O error occurs.
-
write
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:
writein classjj2000.j2k.image.output.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.
-
write
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:
writein classjj2000.j2k.image.output.ImgWriter- Throws:
IOException- If an I/O error occurs.- See Also:
-
writeModImg
- Throws:
IOException
-
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). -
getOffset
public int getOffset() -
setOffset
public void setOffset(int slcIdx) -
setSrc
public void setSrc(jj2000.j2k.image.BlkImgDataSrc slc) -
writeSlice
- Throws:
IOException
-
getImgType
public int getImgType() -
setImgType
public void setImgType(int imgType)
-