## Printer Device Driver

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

### GplDitherRGBtoCMYK

Description

This function performs the dithering.

Format

    APIRET APIENTRY GplDitherRGBtoCMYK( PHDITHER       pdh,

                                        PDITHEREQUEST  pReq

                                        PDITHERESULT   pReply );

Parameters

pdh (PHDITHER) Pointer to the dither handler that was created by GplDitherCreateInstance.

pReq (PDITHEREQUEST) If a diffusion dither algorithm is selected, use the macro GPL_SETUP_DITHER( req, ulLevel ) to set the SrcOptions structure.

or

If Magic Squares or Ordered Squares is selected, the following fields must be set:

lHue
lSaturation
lValue Address of the API's pre-stuffed request structure. The following fields must be set by the API:

fNewColors Must be set to TRUE at the beginning of the page. This element is set to FALSE on return.

If fNewColors equals TRUE, the following two fields must be set:

ulGamma
lBias

pSrcInfo Must have the following two fields set:

cx
cy

If BitsPerPel is less than 16 and fNewColors equals TRUE, the pbmi array, argbColor[256] must be initialized.

pbSrc Pointer to the surface bitmap.

pReply (PDITHERESULT) Pointer to the reply structure.

Returns

Success NO_ERROR 0
Failure INVALID_PARAMETER

Example Code

Following is an example of dithering RGB to CMYK data from the Omni driver' s "render" callback function:

    // Change logical height of band bitmap to 1 (this device chooses to dither each scanline)

    ulSavedcy = pddc->pbmi->cy;

    pddc->pbmi->cy = 1;

    // For each row in the current band's bitmap (each scanline)

    for( iCurrentRow=ulSavedcy; iCurrentRow > 0; iCurrentRow-- )

    {

      // Set pointer to current row in our band's bitmap

      cmykReq.pbSrc = pbBits + iCurrentRow * iDWordBytesInCMYKBandRow;

      GplDitherRGBtoCMYK ( &pddc->pdh, &pddc->cmykReq, &pddc->pReply );

      // Now our consecutive KCMY buffers contain dithered data to send to printer

    } /* end for */

    // Restore bitmap height to TRUE value (no longer 1)

    pddc->pbmi->cy = ulSavedcy;