⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intrface.cpp

📁 WINDDK XP/2003 Microsoft Bitmap Printer Driver Sample Decompress to src in WINDDK and "build -cZ
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        pointed to by pResource. This is zero if pResource is NULL.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 
    E_NOTIMPL The method is not implemented. 


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::HalftonePattern() entry.");

    return E_NOTIMPL;
}

HRESULT __stdcall
COemUni2::
ImageProcessing(
    PDEVOBJ                 pdevobj,  
    PBYTE                   pSrcBitmap,
    PBITMAPINFOHEADER       pBitmapInfoHeader,
    PBYTE                   pColorTable,
    DWORD                   dwCallbackID,
    PIPPARAMS               pIPParams,
    OUT PBYTE               *ppbResult
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::ImageProcessing

    The IPrintOemUni::ImageProcessing method can be used with 
    Unidrv-supported printers to modify image bitmap data, in order 
    to perform color formatting or halftoning. The method can return 
    the modified bitmap to Unidrv or send it directly to the print spooler.
    
    Please refer to DDK documentation for more details.

    The algorithm for this particular implementation of ImageProcessing is as follows.
    - If headers have not been filled as yet, fill them.
    - We fill out only the info header and the color table here. The file header is filled
        out in OEMEndDoc.
    - The height and image size in the bitmap info header are updated every time
        we enter ImageProcessing.
    - Increase the size of the data buffer by the size of the current band.
    - Copy over the data from the current band to the buffer.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pSrcBitmap - pointer to an input device-independent bitmap (DIB). 
    pBitmapInfoHeader - pointer to a BITMAPINFOHEADER structure 
        that describes the bitmap pointed to by pSrcBitmap.  
    pColorTable - pointer to a color table. Used only if the output format is 
        eight bits per pixel. 
    dwCallbackID - value assigned to the *IPCallbackID attribute of the 
        currently selected option for the ColorMode feature. 
    pIPParams - pointer to an IPPARAMS structure. 
    ppbResult - 
        If the method returns the converted DIB to Unidrv: 
            If the conversion succeeds, the method should return a 
                pointer to a buffer containing the converted DIB. 
                Otherwise it should return NULL. 
        If the method sends the converted DIB to the print spooler: 
            If the operation succeeds, the method should return TRUE. 
                Otherwise it should return FALSE.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 
    E_NOTIMPL The method is not implemented. 


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::ImageProcessing() entry.");

    POEMPDEV pOemPDEV = (POEMPDEV)pdevobj->pdevOEM;

    // We want to set ppbResult to NULL in case this function fails and returns E_FAIL
    // 
    *ppbResult = NULL;

    // We want to keep track of the current offset from the start
    // of the buffer before the size is increased.
    // 
    DWORD dwBufOffset = pOemPDEV->dwBufSize;

    // We fill out the file header in OEMEndDoc. But for the info header, we take the easy route
    // and copy the stuff from pBitmapInfoHeader. Only height and image size will be updated
    // every time we enter ImageProcessing.
    //
    if (!pOemPDEV->bHeadersFilled)
    {
        ULONG ulMonoPalette[2] = { RGB_BLACK, RGB_WHITE, };
        
        pOemPDEV->bHeadersFilled = TRUE;
        pOemPDEV->bmInfoHeader.biSize = pBitmapInfoHeader->biSize;
        pOemPDEV->bmInfoHeader.biPlanes = pBitmapInfoHeader->biPlanes;
        pOemPDEV->bmInfoHeader.biBitCount = pBitmapInfoHeader->biBitCount;
        pOemPDEV->bmInfoHeader.biCompression = pBitmapInfoHeader->biCompression;
        pOemPDEV->bmInfoHeader.biXPelsPerMeter = pBitmapInfoHeader->biXPelsPerMeter;
        pOemPDEV->bmInfoHeader.biYPelsPerMeter = pBitmapInfoHeader->biYPelsPerMeter;
        pOemPDEV->bmInfoHeader.biClrUsed = pBitmapInfoHeader->biClrUsed;
        pOemPDEV->bmInfoHeader.biClrImportant = pBitmapInfoHeader->biClrImportant;
        pOemPDEV->bmInfoHeader.biWidth = pBitmapInfoHeader->biWidth;        // We support only Portrait. So width is constant and needs to be updated only once.

        if (dwCallbackID != BMF_24BPP)  // We need color table only if it is not 24bpp
        {
            pOemPDEV->bColorTable = TRUE;   // Indicates that color table needs to be dumped at EndDoc time

            switch(dwCallbackID)
            {
                case BMF_1BPP:  // 1
                    pOemPDEV->cPalColors = 2;
                    pOemPDEV->prgbq = (RGBQUAD *)LocalAlloc(LPTR, pOemPDEV->cPalColors * sizeof(RGBQUAD));
                    if (pOemPDEV->prgbq == NULL)
                        return E_FAIL;
                    for (int i = 0; i < pOemPDEV->cPalColors; i++)
                    {
                        pOemPDEV->prgbq[i].rgbBlue  = GetBValue(ulMonoPalette[i]);
                        pOemPDEV->prgbq[i].rgbGreen = GetGValue(ulMonoPalette[i]);
                        pOemPDEV->prgbq[i].rgbRed   = GetRValue(ulMonoPalette[i]);
                    }
                    break;
                case BMF_4BPP:  // 2
                    pOemPDEV->cPalColors = 16;
                    if (!bFillColorTable(pOemPDEV))
                        return E_FAIL;
                    break;
                case BMF_8BPP:  // 3
                    pOemPDEV->cPalColors = 256;
                    if (!bFillColorTable(pOemPDEV))
                        return E_FAIL;
                    break;
            }
        }

    }

    // Keep track of the overall height and image size
    //
    pOemPDEV->bmInfoHeader.biHeight += pBitmapInfoHeader->biHeight;
    pOemPDEV->bmInfoHeader.biSizeImage += pBitmapInfoHeader->biSizeImage;

    // Increase the buffer by the size of the current band
    //
    if (!bGrowBuffer(pOemPDEV, pBitmapInfoHeader->biSizeImage))
        return E_FAIL;

    if (!pIPParams->bBlankBand)     // Non-blank band
    {
        CopyMemory((pOemPDEV->pBufStart + dwBufOffset), pSrcBitmap, pBitmapInfoHeader->biSizeImage);
    }
    else        // For blanks bands, buffer blank scanlines
    {
        memset((pOemPDEV->pBufStart + dwBufOffset), 0xff, pBitmapInfoHeader->biSizeImage);
    }

    // Set ppbResult to TRUE
    //
    *ppbResult = (LPBYTE)(INT_PTR)(TRUE);

    return S_OK;
}

HRESULT __stdcall
COemUni2::
MemoryUsage(
    PDEVOBJ             pdevobj,   
    POEMMEMORYUSAGE pMemoryUsage
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::MemoryUsage

    The IPrintOemUni::MemoryUsage method can be used with 
    Unidrv-supported printers to specify the amount of memory 
    required for use by a rendering plug-in's IPrintOemUni::ImageProcessing 
    method.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pMemoryUsage - pointer to an OEMMEMORYUSAGE structure.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 
    E_NOTIMPL The method is not implemented. 


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::MemoryUsage() entry.");

    return E_NOTIMPL;
}

HRESULT __stdcall
COemUni2::
OutputCharStr(
    PDEVOBJ         pdevobj,
    PUNIFONTOBJ     pUFObj,
    DWORD           dwType,
    DWORD           dwCount,
    PVOID           pGlyph
    ) 

/*++

Routine Description:

    Implementation of IPrintOemUni::OutputCharStr

    The IPrintOemUni::OutputCharStr method enables a rendering 
    plug-in to control the printing of font glyphs.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pUFObj - pointer to a UNIFONTOBJ structure. 
    dwType - value indicating the type of glyph specifier array 
        pointed to by pGlyph. Valid values are as follows: 
        TYPE_GLYPHHANDLE The pGlyph array elements are glyph 
            handles of type HGLYPH. 
        TYPE_GLYPHID The pGlyph array elements are glyph 
            identifiers of type DWORD. 
    dwCount - value representing the number of glyph specifiers in 
        the array pointed to by pGlyph. 
    pGlyph - pointer to an array of glyph specifiers, where the array 
        element type is indicated by dwType.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 
    E_NOTIMPL The method is not implemented. 


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::OutputCharStr() entry.");

    return E_NOTIMPL;
}

HRESULT __stdcall
COemUni2::
PublishDriverInterface(
    IUnknown *pIUnknown
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::PublishDriverInterface

    The IPrintOemUni::PublishDriverInterface method allows a 
    rendering plug-in for Unidrv to obtain the Unidrv driver's 
    IPrintOemDriverUni interface.

    A rendering plug-in for Unidrv MUST implement the 
    IPrintOemUni::PublishDriverInterface method and the method 
    must return S_OK, or the driver will not call the plug-in's other 
    IPrintOemUni interface methods.
    
    Please refer to DDK documentation for more details.

Arguments:

    pIUnknown - pointer to the IUnknown interface of the driver's 
        IPrintOemDriverUni COM interface.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::PublishDriverInterface() entry.");

    // Need to store pointer to Driver Helper functions, if we already haven't.
    if (this->m_pOEMHelp == NULL)
    {
        HRESULT hResult;

        // Get Interface to Helper Functions.
        hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUni, (void** ) &(this->m_pOEMHelp));

        if(!SUCCEEDED(hResult))
        {
            // Make sure that interface pointer reflects interface query failure.
            this->m_pOEMHelp = NULL;

            return E_FAIL;
        }
    }

    return S_OK;
}

HRESULT __stdcall
COemUni2::
ResetPDEV(
    PDEVOBJ     pdevobjOld,
    PDEVOBJ     pdevobjNew
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::ResetPDEV

    The IPrintOemUni::ResetPDEV method allows a rendering 
    plug-in for Unidrv to reset its PDEV structure.

    A rendering plug-in for Unidrv MUST implement the 
    IPrintOemUni::ResetPDEV method.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobjOld - pointer to a DEVOBJ structure containing current PDEV information. 
    pdevobjNew - pointer to a DEVOBJ structure into which the method should place 
        new PDEV information. 
    
Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 


--*/

{
    BOOL    bResult;

    OEMDBG(DBG_VERBOSE, L"COemUni2::ResetPDEV() entry.");

    bResult = OEMResetPDEV(pdevobjOld, pdevobjNew);     // Implemented in enable.cpp

    return (bResult ? S_OK : E_FAIL);
}

HRESULT __stdcall
COemUni2::
SendFontCmd(
    PDEVOBJ         pdevobj,
    PUNIFONTOBJ     pUFObj,
    PFINVOCATION    pFInv
    ) 

/*++

Routine Description:

    Implementation of IPrintOemUni::SendFontCmd

    The IPrintOemUni::SendFontCmd method enables a rendering 
    plug-in to modify a printer's font selection command and then 
    send it to the printer.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pUFObj - pointer to a UNIFONTOBJ structure. 
    pFInv - pointer to an FINVOCATION structure.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 
    E_NOTIMPL The method is not implemented. 


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::SendFontCmd() entry.");

    return E_NOTIMPL;
}

HRESULT __stdcall
COemUni2::
TextOutAsBitmap(
    SURFOBJ         *pso,
    STROBJ          *pstro,
    FONTOBJ         *pfo,
    CLIPOBJ         *pco,
    RECTL           *prclExtra,
    RECTL           *prclOpaque,
    BRUSHOBJ        *pboFore,
    BRUSHOBJ        *pboOpaque,
    POINTL          *pptlOrg,
    MIX             mix
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::TextOutAsBitmap

    The IPrintOemUni::TextOutAsBitmap method allows a rendering 
    plug-in to create a bitmap image of a text string, in case a 
    downloadable font is not available.
    
    Please refer to DDK documentation for more details.

Arguments:

    pso - Defines the surface on which to be written.
    pstro - Defines the glyphs to be rendered and their positions
    pfo - Specifies the font to be used
    pco - Defines the clipping path
    prclExtra - A NULL-terminated array of rectangles to be filled
    prclOpaque - Specifies an opaque rectangle
    pboFore - Defines the foreground brush
    pboOpaque - Defines the opaque brush
    pptlOrg - Pointer to POINT struct , defining th origin
    mix - Specifies the foreground and background ROPs for pboFore

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 
    E_NOTIMPL The method is not implemented. 


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::TextOutAsBitmap() entry.");

    return E_NOTIMPL;
}

HRESULT __stdcall
COemUni2::
TTDownloadMethod(
    PDEVOBJ         pdevobj,
    PUNIFONTOBJ     pUFObj,
    OUT DWORD       *pdwResult
    ) 

/*++

Routine Description:

    Implementation of IPrintOemUni::TTDownloadMethod

    The IPrintOemUni::TTDownloadMethod method enables a rendering 
    plug-in to indicate the format that Unidrv should use for a specified 
    TrueType soft font.
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -