C# Class CSJ2K.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 data.

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 omited, values are supposed to be unsigned.
  • bit-depth that can be any number between 1 and 31.
  • width and height are the image dimensions (in pixels).
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.

Inheritance: CSJ2K.j2k.image.output.ImgWriter
显示文件 Open project: cureos/csj2k

Public Methods

Method Description
ImgWriterPGX ( IFileInfo out_Renamed, BlkImgDataSrc imgSrc, int c, bool isSigned ) : System

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).

ImgWriterPGX ( System fname, BlkImgDataSrc imgSrc, int c, bool isSigned ) : System

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).

ToString ( ) : System.String

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).

close ( ) : void

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.

flush ( ) : void

Writes all buffered data to the file or resource.

write ( ) : void

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.

write ( int ulx, int uly, int w, int h ) : void

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.

Method Details

ImgWriterPGX() public method

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).

public ImgWriterPGX ( IFileInfo out_Renamed, BlkImgDataSrc imgSrc, int c, bool isSigned ) : System
out_Renamed IFileInfo
imgSrc BlkImgDataSrc The source from where to get the image data to write. /// ///
c int The index of the component from where to get the data. /// ///
isSigned bool Whether the datas are signed or not (needed only when /// writing header). /// ///
return System

ImgWriterPGX() public method

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).

public ImgWriterPGX ( System fname, BlkImgDataSrc imgSrc, int c, bool isSigned ) : System
fname System The name of the file where to write the data /// ///
imgSrc BlkImgDataSrc The source from where to get the image data to write. /// ///
c int The index of the component from where to get the data. /// ///
isSigned bool Whether the datas are signed or not (needed only when /// writing header). /// ///
return System

ToString() public method

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).
public ToString ( ) : System.String
return System.String

close() public method

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.
If an I/O error occurs. /// ///
public close ( ) : void
return void

flush() public method

Writes all buffered data to the file or resource.
If an I/O error occurs. /// ///
public flush ( ) : void
return void

write() public method

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.

If an I/O error occurs. /// ///
public write ( ) : void
return void

write() public method

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.

If an I/O error occurs. /// ///
public write ( int ulx, int uly, int w, int h ) : void
ulx int The horizontal coordinate of the upper-left corner of the /// area to write, relative to the current tile. /// ///
uly int The vertical coordinate of the upper-left corner of the area /// to write, relative to the current tile. /// ///
w int
h int
return void