jj2000.j2k.fileformat.writer
Class FileFormatWriter

java.lang.Object
  |
  +--jj2000.j2k.fileformat.writer.FileFormatWriter
All Implemented Interfaces:
FileFormatBoxes

public class FileFormatWriter
extends java.lang.Object
implements FileFormatBoxes

This class writes the file format wrapper that may or may not exist around a valid JPEG 2000 codestream. This class writes the simple possible legal fileformat

See Also:
FileFormatReader

Field Summary
private  int[] bpc
          Bits per component
private static int BPC_LENGTH
          base length of Bits Per Component box
private  boolean bpcVaries
          Flag indicating whether number of bits per component varies
private  int clength
          Length of codestream
private static int CSB_LENGTH
          Length of Colour Specification Box
private  BEBufferedRandomAccessFile fi
          The file from which to read the codestream and write file
private  java.lang.String filename
          The name of the file from which to read the codestream and to write the JP2 file
private static int FTB_LENGTH
          Length of File Type Box
private  int height
          Image height
private static int IHB_LENGTH
          Length of Image Header Box
private  int nc
          Number of components
private  int width
          Image width
 
Fields inherited from interface jj2000.j2k.fileformat.FileFormatBoxes
BITS_PER_COMPONENT_BOX, CAPTURE_RESOLUTION_BOX, CHANNEL_DEFINITION_BOX, COLOUR_SPECIFICATION_BOX, COMPONENT_MAPPING_BOX, CONTIGUOUS_CODESTREAM_BOX, CSB_APPROX, CSB_ENUM_GREY, CSB_ENUM_SRGB, CSB_METH, CSB_PREC, DEFAULT_DISPLAY_RESOLUTION_BOX, FILE_TYPE_BOX, FT_BR, IMAGE_HEADER_BOX, IMB_C, IMB_IPR, IMB_UnkC, IMB_VERS, INTELLECTUAL_PROPERTY_BOX, JP2_HEADER_BOX, JP2_SIGNATURE_BOX, PALETTE_BOX, RESOLUTION_BOX, URL_BOX, UUID_BOX, UUID_INFO_BOX, UUID_LIST_BOX, XML_BOX
 
Constructor Summary
FileFormatWriter(java.lang.String filename, int height, int width, int nc, int[] bpc, int clength)
          The constructor of the FileFormatWriter.
 
Method Summary
 void writeBitsPerComponentBox()
          This method writes the Bits Per Component box
 void writeColourSpecificationBox()
          This method writes the Colour Specification box
 void writeContiguousCodeStreamBox(byte[] cs)
          This method writes the Contiguous codestream box
 int writeFileFormat()
          This method reads the codestream and writes the file format wrapper and the codestream to the same file
 void writeFileTypeBox()
          This method writes the File Type box
 void writeImageHeaderBox()
          This method writes the Image Header box
 void writeJP2HeaderBox()
          This method writes the JP2Header box
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fi

private BEBufferedRandomAccessFile fi
The file from which to read the codestream and write file


filename

private java.lang.String filename
The name of the file from which to read the codestream and to write the JP2 file


height

private int height
Image height


width

private int width
Image width


nc

private int nc
Number of components


bpc

private int[] bpc
Bits per component


bpcVaries

private boolean bpcVaries
Flag indicating whether number of bits per component varies


clength

private int clength
Length of codestream


CSB_LENGTH

private static final int CSB_LENGTH
Length of Colour Specification Box

See Also:
Constant Field Values

FTB_LENGTH

private static final int FTB_LENGTH
Length of File Type Box

See Also:
Constant Field Values

IHB_LENGTH

private static final int IHB_LENGTH
Length of Image Header Box

See Also:
Constant Field Values

BPC_LENGTH

private static final int BPC_LENGTH
base length of Bits Per Component box

See Also:
Constant Field Values
Constructor Detail

FileFormatWriter

public FileFormatWriter(java.lang.String filename,
                        int height,
                        int width,
                        int nc,
                        int[] bpc,
                        int clength)
The constructor of the FileFormatWriter. It receives all the information necessary about a codestream to generate a legal JP2 file

Parameters:
filename - The name of the file that is to be made a JP2 file
height - The height of the image
width - The width of the image
nc - The number of components
bpc - The number of bits per component
clength - Length of codestream
Method Detail

writeFileFormat

public int writeFileFormat()
                    throws java.io.IOException
This method reads the codestream and writes the file format wrapper and the codestream to the same file

Returns:
The number of bytes increases because of the file format
Throws:
java.io.IOException - If an I/O error ocurred.

writeFileTypeBox

public void writeFileTypeBox()
                      throws java.io.IOException
This method writes the File Type box

Throws:
java.io.IOException - If an I/O error ocurred.

writeJP2HeaderBox

public void writeJP2HeaderBox()
                       throws java.io.IOException
This method writes the JP2Header box

Throws:
java.io.IOException - If an I/O error ocurred.

writeBitsPerComponentBox

public void writeBitsPerComponentBox()
                              throws java.io.IOException
This method writes the Bits Per Component box

Throws:
java.io.IOException - If an I/O error ocurred.

writeColourSpecificationBox

public void writeColourSpecificationBox()
                                 throws java.io.IOException
This method writes the Colour Specification box

Throws:
java.io.IOException - If an I/O error ocurred.

writeImageHeaderBox

public void writeImageHeaderBox()
                         throws java.io.IOException
This method writes the Image Header box

Throws:
java.io.IOException - If an I/O error ocurred.

writeContiguousCodeStreamBox

public void writeContiguousCodeStreamBox(byte[] cs)
                                  throws java.io.IOException
This method writes the Contiguous codestream box

Parameters:
cs - The contiguous codestream
Throws:
java.io.IOException - If an I/O error ocurred.