Class T4AndT6Compression
java.lang.Object
org.apache.commons.imaging.formats.tiff.itu_t4.T4AndT6Compression
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprivate static final HuffmanTree<Integer> private static final HuffmanTree<T4_T6_Tables.Entry> static final intprivate static final HuffmanTree<Integer> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intchangingElementAt(int[] line, int position) private static voidcompress1DLine(BitInputStreamFlexible inputStream, BitArrayOutputStream outputStream, int[] referenceLine, int width) static byte[]compressModifiedHuffman(byte[] uncompressed, int width, int height) Compressed with the "Modified Huffman" encoding of section 10 in the TIFF6 specification.private static intcompressT(int a0, int a1, int b1, BitArrayOutputStream outputStream, int codingA0Color, int[] codingLine) static byte[]compressT4_1D(byte[] uncompressed, int width, int height, boolean hasFill) static byte[]compressT4_2D(byte[] uncompressed, int width, int height, boolean hasFill, int parameterK) static byte[]compressT6(byte[] uncompressed, int width, int height) static byte[]decompressModifiedHuffman(byte[] compressed, int width, int height) Decompresses the "Modified Huffman" encoding of section 10 in the TIFF6 specification.static byte[]decompressT4_1D(byte[] compressed, int width, int height, boolean hasFill) Decompresses T.4 1D encoded data.static byte[]decompressT4_2D(byte[] compressed, int width, int height, boolean hasFill) Decompressed T.4 2D encoded data.static byte[]decompressT6(byte[] compressed, int width, int height) Decompress T.6 encoded data.private static voidfillRange(BitArrayOutputStream outputStream, int[] referenceRow, int a0, int end, int color) private static booleanisEol(T4_T6_Tables.Entry entry, boolean hasFill) private static T4_T6_Tables.EntrylowerBound(T4_T6_Tables.Entry[] entries, int value) private static intnextChangingElement(int[] line, int currentColour, int start) private static intreadTotalRunLength(BitInputStreamFlexible bitStream, int color) private static voidwriteRunLength(BitArrayOutputStream bitStream, int runLength, int color)
-
Field Details
-
WHITE_RUN_LENGTHS
-
BLACK_RUN_LENGTHS
-
CONTROL_CODES
-
WHITE
public static final int WHITE- See Also:
-
BLACK
public static final int BLACK- See Also:
-
-
Constructor Details
-
T4AndT6Compression
private T4AndT6Compression()
-
-
Method Details
-
changingElementAt
private static int changingElementAt(int[] line, int position) -
compress1DLine
private static void compress1DLine(BitInputStreamFlexible inputStream, BitArrayOutputStream outputStream, int[] referenceLine, int width) throws ImagingException - Throws:
ImagingException
-
compressModifiedHuffman
public static byte[] compressModifiedHuffman(byte[] uncompressed, int width, int height) throws ImagingException Compressed with the "Modified Huffman" encoding of section 10 in the TIFF6 specification. No EOLs, no RTC, rows are padded to end on a byte boundary.- Parameters:
uncompressed- uncompressed byte datawidth- image widthheight- image height- Returns:
- the compressed data
- Throws:
ImagingException- if it fails to write the compressed data
-
compressT
private static int compressT(int a0, int a1, int b1, BitArrayOutputStream outputStream, int codingA0Color, int[] codingLine) -
compressT4_1D
public static byte[] compressT4_1D(byte[] uncompressed, int width, int height, boolean hasFill) throws ImagingException - Throws:
ImagingException
-
compressT4_2D
public static byte[] compressT4_2D(byte[] uncompressed, int width, int height, boolean hasFill, int parameterK) throws ImagingException - Throws:
ImagingException
-
compressT6
- Throws:
ImagingException
-
decompressModifiedHuffman
public static byte[] decompressModifiedHuffman(byte[] compressed, int width, int height) throws ImagingException Decompresses the "Modified Huffman" encoding of section 10 in the TIFF6 specification. No EOLs, no RTC, rows are padded to end on a byte boundary.- Parameters:
compressed- compressed byte datawidth- image widthheight- image height- Returns:
- the compressed data
- Throws:
ImagingException- if it fails to read the compressed data
-
decompressT4_1D
public static byte[] decompressT4_1D(byte[] compressed, int width, int height, boolean hasFill) throws ImagingException Decompresses T.4 1D encoded data. EOL at the beginning and after each row, can be preceded by fill bits to fit on a byte boundary, no RTC.- Parameters:
compressed- compressed byte datawidth- image widthheight- image heighthasFill- used to check the end of line- Returns:
- the decompressed data
- Throws:
ImagingException- if it fails to read the compressed data
-
decompressT4_2D
public static byte[] decompressT4_2D(byte[] compressed, int width, int height, boolean hasFill) throws ImagingException Decompressed T.4 2D encoded data. EOL at the beginning and after each row, can be preceded by fill bits to fit on a byte boundary, and is succeeded by a tag bit determining whether the next line is encoded using 1D or 2D. No RTC.- Parameters:
compressed- compressed byte datawidth- image widthheight- image heighthasFill- used to check the end of line- Returns:
- the decompressed data
- Throws:
ImagingException- if it fails to read the compressed data
-
decompressT6
Decompress T.6 encoded data. No EOLs, except for 2 consecutive ones at the end (the EOFB, end of fax block). No RTC. No fill bits anywhere. All data is 2D encoded.- Parameters:
compressed- compressed byte datawidth- image widthheight- image height- Returns:
- the decompressed data
- Throws:
ImagingException- if it fails to read the compressed data
-
fillRange
private static void fillRange(BitArrayOutputStream outputStream, int[] referenceRow, int a0, int end, int color) -
isEol
-
lowerBound
-
nextChangingElement
private static int nextChangingElement(int[] line, int currentColour, int start) -
readTotalRunLength
private static int readTotalRunLength(BitInputStreamFlexible bitStream, int color) throws ImagingException - Throws:
ImagingException
-
writeRunLength
-