## Printer Device Driver

[prev][next][parent][TOC]

### GplFaxG3EncodeBlock

Description

This function performs G3 "Fax"-type compression.

It provides a run-length type compression with table-lookup replacement encodings for certain bit sequences. This type of compression is also know as "Modified Huffman."

Format

    GplFaxG3EncodeBlock( HTHREAD  hThread,

                         PBYTE    pbOutput,

                         ULONG    ulOutputSize,

                         PULONG   pulBitposition,

                         PBYTE    pbInput,

                         ULONG    ulBitwide,

                         ULONG    ulBitheight,

                         PFN      pfnFlushBuffer );

Parameters

hThread (HTHREAD) Handle.

pbOutput (PBYTE) Pointer to output buffer to fill.

ulOutputSize (ULONG) Number of output bytes; must be divisible by 4.

pulBitposition (PULONG) Pointer to bit position in output buffer; gets updated and must be stored off the pddc.

pbInput (PBYTE) Input pointer to upper left corner of raster image to compress.

ulBitwide (ULONG) Width of raster image to compress in bits; must be less than or equal to 2560 + 63 = 2623.

ulBitheight (ULONG) Height of raster image to compress in bits.

pfnFlushBuffer (PFN) The prototype for this function must be:

    void   pfnFlushBuffer ( PVOID,

                            PBYTE,

                            ULONG );

PVOID Use is the same as G4.

PBYTE Unsigned char * to output buffer; same as pbOutput.

ULONG Unsigned long; size of pbOutput buffer; same as ulOutputSize.

Returns

Success Count of data written out (compressed data count).
Failure GPLCOMPRESS_ERROR (-1)

Related Functions The following G3 "Fax"-compression related functions provide help in sending down special G3 commands.

GplFaxG3StartBlock() Modified Huffman (MH) Group 3 end of line (EOL) sent at the beginning of the first page. This function outputs the EOL to pbOutput and initializes pulBitposition to 12. It simply sends out the EOL bit sequence to signal the start of raster data (for example, '000000000001 ' binary, eleven 0's and a single 1).

Inputs

pbOutput Output buffer to fill
pulBitposition Bit-position count in the output buffer

Returns Void

GplFaxG3EndBlock() End of block flushed.

    GplFaxG3EndBlock( PVOID    hThread,

                      PBYTE    pbOutput,

                      ULONG    ulOutputSize,

                      PULONG   pulBitposition

                      PFN      pfnFlushBuffer );

Inputs

hThread PVOID.

pbOutput Output buffer to fill.

ulOutputSize Size in bytes of output buffer; must be a multiple of 32 bits; must be divisible by 4.

pulBitposition Bit-position count in the output buffer; *pulBitposition gets updated and must be stored off the pddc.

pfnFlushBuffer Flush buffer function; prototype for this function must be:

    void   pfnFlushBuffer( PVOID,

                           PBYTE,

                           ULONG );

PVOID Use is the same as above.

PBYTE Unsigned char to output buffer; same as pbOutput.

ULONG Unsigned long; size of pbOutput buffer; same as ulOutputSize.

Returns

Success Count of data written out (compressed data count).

Failure GPLCOMPRESS_ERROR (-1).

GplFaxG3EndDoc() Modified Huffman (MH) Group 3 return to control (RTC) sent at the end of document.

    GplFaxG3EndDoc( PVOID    hThread,

                    PBYTE    pbOutput,

                    ULONG    ulOutputSize,

                    PULONG   pulBitposition

                    PFN      pfnFlushBuffer );

Inputs

hThread PVOID.

pbOutput Output buffer to fill.

ulOutputSize Size in bytes of output buffer; must be a multiple of 32 bits; must be divisible by 4.

pulBitposition Bit-position count in the output buffer; gets updated and must be stored off the pddc.

pfnFlushBuffer Flush buffer function; prototype for this function must be:

    void   pfnFlushBuffer( PVOID,

                           PBYTE,

                           ULONG );

PVOID Use is the same as above.

PBYTE Unsigned char to output buffer; same as pbOutput.

ULONG Unsigned long; size of pbOutput buffer; same as ulOutputSize.

Returns

Success Count of data written out (compressed data count).

Failure GPLCOMPRESS_ERROR (-1).

GplFaxG3NewFrame() Modified Huffman (MH) Group 3 end of line (EOL) sent at the beginning of each new page. This function is the same as GplFaxG3EncodeBlock() except that it flushes data at this point to cause the current page to be completely sent. This call sends compressed data followed by the EOL bit sequence (see GplFaxG3StartBlock).

Instead of GplFaxG3NewFrame() you can use pfnFlushBuffer() = NULL to see whether or not the buffer for GplFaxG3EncodeBlock() is large enough. You output the bytes after GplFaxG3EncodeBlock() returns OK. You can then call GplFaxG3StartBlock(). This function places an EOL in the output buffer and sets the pulBitposition to 12.

    GplFaxG3NewFrame( HTHREAD  hThread,

                      PBYTE    pbOutput,

                      ULONG    ulOutputSize,

                      PULONG   pulBitposition

                      PFN      pfnFlushBuffer );

Inputs

hThread HTHREAD

pbOutput Output buffer to fill.

ulOutputSize Size in bytes of output buffer; must be a multiple of 32 bits.

pulBitposition Bit-position count in the output buffer.

pfnFlushBuffer Flush buffer function; prototype for this function must be:

    void   pfnFlushBuffer( PVOID,

                           PBYTE,

                           ULONG );

PVOID Use is the same as above.

PBYTE Unsigned char to output buffer; same as pbOutput.

ULONG Unsigned long; size of pbOutput buffer; same as ulOutputSize.

Returns

Success Count of data written out (compressed data count).

Failure GPLCOMPRESS_ERROR (-1)