com.lowagie.text.pdf.codec

## Class CCITTG4Encoder

- java.lang.Object
- - com.lowagie.text.pdf.codec.CCITTG4Encoder

-     public class CCITTG4Encoder
      extends java.lang.Object

  Encodes data in the CCITT G4 FAX format.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private int` | `bit`
    `private static int` | `CODE`
    `private int` | `data`
    `private byte[]` | `dataBp`
    `private static int` | `EOL`
    `private static int` | `G3CODE_EOF`
    `private static int` | `G3CODE_EOL`
    `private static int` | `G3CODE_INCOMP`
    `private static int` | `G3CODE_INVALID`
    `private int[]` | `horizcode`
    `private static int` | `LENGTH`
    `private int[]` | `msbmask`
    `private int` | `offsetData`
    `private static byte[]` | `oneruns`
    `private ByteBuffer` | `outBuf`
    `private int[]` | `passcode`
    `private byte[]` | `refline`
    `private int` | `rowbytes`
    `private int` | `rowpixels`
    `private static int` | `RUNLEN`
    `private int` | `sizeData`
    `private int[][]` | `TIFFFaxBlackCodes`
    `private int[][]` | `TIFFFaxWhiteCodes`
    `private int[][]` | `vcodes`
    `private static byte[]` | `zeroruns`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CCITTG4Encoder(int width)` Creates a new encoder.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `close()` Closes the encoder and returns the encoded data.
    `static byte[]` | `compress(byte[] data, int width, int height)` Encodes a full image.
    `private void` | `Fax3Encode2DRow()`
    `void` | `fax4Encode(byte[] data, int height)` Encodes a number of lines.
    `void` | `fax4Encode(byte[] data, int offset, int size)` Encodes a number of lines.
    `private void` | `Fax4PostEncode()`
    `private static int` | `find0span(byte[] bp, int offset, int bs, int be)`
    `private static int` | `find1span(byte[] bp, int offset, int bs, int be)`
    `private static int` | `finddiff(byte[] bp, int offset, int bs, int be, int color)`
    `private static int` | `finddiff2(byte[] bp, int offset, int bs, int be, int color)`
    `private int` | `pixel(byte[] data, int offset, int bit)`
    `private void` | `putBits(int bits, int length)`
    `private void` | `putcode(int[] table)`
    `private void` | `putspan(int span, int[][] tab)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### rowbytes

          private int rowbytes

    - #### rowpixels

          private int rowpixels

    - #### bit

          private int bit

    - #### data

          private int data

    - #### refline

          private byte[] refline

    - #### outBuf

          private ByteBuffer outBuf

    - #### dataBp

          private byte[] dataBp

    - #### offsetData

          private int offsetData

    - #### sizeData

          private int sizeData

    - #### zeroruns

          private static byte[] zeroruns

    - #### oneruns

          private static byte[] oneruns

    - #### LENGTH

          private static final int LENGTH

      See Also:
        Constant Field Values

    - #### CODE

          private static final int CODE

      See Also:
        Constant Field Values

    - #### RUNLEN

          private static final int RUNLEN

      See Also:
        Constant Field Values

    - #### EOL

          private static final int EOL

      See Also:
        Constant Field Values

    - #### G3CODE_EOL

          private static final int G3CODE_EOL

      See Also:
        Constant Field Values

    - #### G3CODE_INVALID

          private static final int G3CODE_INVALID

      See Also:
        Constant Field Values

    - #### G3CODE_EOF

          private static final int G3CODE_EOF

      See Also:
        Constant Field Values

    - #### G3CODE_INCOMP

          private static final int G3CODE_INCOMP

      See Also:
        Constant Field Values

    - #### TIFFFaxWhiteCodes

          private int[][] TIFFFaxWhiteCodes

    - #### TIFFFaxBlackCodes

          private int[][] TIFFFaxBlackCodes

    - #### horizcode

          private int[] horizcode

    - #### passcode

          private int[] passcode

    - #### vcodes

          private int[][] vcodes

    - #### msbmask

          private int[] msbmask

  - ### Constructor Detail

    - #### CCITTG4Encoder

          public CCITTG4Encoder(int width)

      Creates a new encoder.
      Parameters:
        `width` - the line width

  - ### Method Detail

    - #### fax4Encode

          public void fax4Encode(byte[] data,
                        int offset,
                        int size)

      Encodes a number of lines.
      Parameters:
        `data` - the data to be encoded
        `offset` - the offset into the data
        `size` - the size of the data to be encoded

    - #### compress

          public static byte[] compress(byte[] data,
                        int width,
                        int height)

      Encodes a full image.
      Parameters:
        `data` - the data to encode
        `width` - the image width
        `height` - the image height
      Returns:
        the encoded image

    - #### fax4Encode

          public void fax4Encode(byte[] data,
                        int height)

      Encodes a number of lines.
      Parameters:
        `data` - the data to be encoded
        `height` - the number of lines to encode

    - #### putcode

          private void putcode(int[] table)

    - #### putspan

          private void putspan(int span,
                     int[][] tab)

    - #### putBits

          private void putBits(int bits,
                     int length)

    - #### Fax3Encode2DRow

          private void Fax3Encode2DRow()

    - #### Fax4PostEncode

          private void Fax4PostEncode()

    - #### close

          public byte[] close()

      Closes the encoder and returns the encoded data.
      Returns:
        the encoded data

    - #### pixel

          private int pixel(byte[] data,
                  int offset,
                  int bit)

    - #### find1span

          private static int find1span(byte[] bp,
                      int offset,
                      int bs,
                      int be)

    - #### find0span

          private static int find0span(byte[] bp,
                      int offset,
                      int bs,
                      int be)

    - #### finddiff

          private static int finddiff(byte[] bp,
                     int offset,
                     int bs,
                     int be,
                     int color)

    - #### finddiff2

          private static int finddiff2(byte[] bp,
                      int offset,
                      int bs,
                      int be,
                      int color)