## Printer Device Driver

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

### GplFaxG4EncodeBlock

Description

This function performs G4 "Fax"-type compression.

It is similar to GplFaxG3EncodeBlock(), but it has five extra parameters. These extra parameters are used to keep track of on/off bit runs between calls.

The driver is again responsible for all memory allocations.

Make sure all buffers for on/off bit tracking are equal to scanline DWORD aligned.

Format

    GplFaxG4EncodeBlock( PVOID   pddc,

                         PBYTE   pbOutput,

                         ULONG   ulOutputSize,

                         PULONG  pulBitposition,

                         PBYTE   pbInput,

                         ULONG   ulBitwide,

                         ULONG   ulBitheight,

                         PFN     pfnFlushBuffer,

                         PULONG  pulwstartc,

                         PULONG  pulbstartc,

                         PULONG  pulwstartp,

                         PULONG  pulbstartp,

                         ULONG   ulSkipCount );

Parameters

pddc (PVOID) First parameter to pfnFlushBuffer; generally pddc or hThread.

pbOutput (PBYTE) Pointer to output buffer to fill.

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

pulBitposition (PULONG) Pointer to position in the output buffer; gets updated and must be unique to each print job; *pulBitposition must be zero on the first invocation of this function for a block.

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 G3; necessary parameter for separating printout; generally pddc or hThread.

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

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

pfnFlushBuffer can be either NULL or point to a function that you supply that will write the compressed bytes out. If pfnFlushBuffer is not NULL, this function will be called when output buffer is full. If pfnFlushBuffer is NULL, you must write the bytes out yourself.

If pfnFlushBuffer() = NULL this function will compress the data and place it into pbOutput. If the output buffer size is not large enough for all the compressed data, the function will return with -1 = error. If pfnFlushBuffer() is not NULL, every time pbOutput is full, pfnFlushBuffer( ) is called to write the compressed bytes out. Note that the return value will the total number of bytes written even though the buffer was filled multiple times.

pulwstartc (PULONG) Pointer to array of ULONGs. Its length must be ( ulBitwide + 31 ) / 32 + 2. The 2 extra ULONGs are needed. So for an image of 371 bits width, the length of this array is ( 371 + 31 ) / 32 = 12 plus 2 more-which is 14 unsigned longs. This array is used to store the start bits of the beginning of consecutive 0 bits for the current scan line.

pulbstartc (PULONG) Size is the same calculation as above. This array is used to store the start bits of the beginning of consecutive 1 bits for the current scan line.

pulwstartp (PULONG) Size is the same calculation as above. This array is used to store the start bits of the beginning of consecutive 0 bits for the previous scan line. This must be zero filled on the first invocation of this function.

pulbstartp (PULONG) Size is the same calculation as above. This array is used to store the start bits of the beginning of consecutive 1 bits for the previous scan line. This must be zero filled on the first invocation of this function.

ulSkipCount (ULONG) Number of bytes to skip to the next row of input data to compress.

Returns

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

Related Function The following is a G4-compression related function automatically sends the "End Block" data sequence (24 bits represented by Hex 001001).

GplFaxG4EndBlock() Modified Read ( MRR) Group 4 compression with K = infinity for sending end-of-facsimile block (EOFB). This function has the same first eight parameters as GplFaxG4EncodeBlock().

    GplFaxG4EndBlock( PVOID   pHandle,

                      PBYTE   pbOutput,

                      ULONG   ulOutputSize,

                      PULONG  pulBitposition,

                      PBYTE   pbInput,

                      ULONG   ulBitwide,

                      ULONG   ulBitheight,

                      PFN     pfnFlushBuffer );

Inputs

pddc PVOID; used as first parameter to the pfnFlushBuffer function; generally the pddc or HTHREAD.

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 unique to each print job.

ulBitwide Width of the raster image in bits.

ulBitheight Height of the raster image in bits.

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

    void   pfnFlushBuffer( PVOID,

                           PBYTE,

                           ULONG );

PVOID Necessary parameter for separating printout; generally pddc or hThread.

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

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

pfnFlushBuffer can be either NULL or point to the function you supply that will write the compressed bytes out. If pfnFlushBuffer is not NULL, this function will be called when the output buffer is full. If pfnFlushBuffer is NULL, you must write the bytes out yourself.

Returns

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