summaryrefslogtreecommitdiff
path: root/print/OEM Printer Customization Plug-in Samples/C++/bitmap/bitmap.h
blob: ee068c02f88a67698269a12b68eef9ac195a50b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
//  Copyright  1997 - 2003  Microsoft Corporation.  All Rights Reserved.
//
//  FILE:   BITMAP.H
//    
//
//  PURPOSE:    Define the COemPDEV class which stores the private
//          PDEV for the driver.
//


#pragma once

#define OEM_SIGNATURE   'MSFT'
#define OEM_VERSION     0x00000001L

#define RGB_BLACK   RGB(0, 0, 0)
#define RGB_WHITE   RGB(255, 255, 255)

class COemPDEV
{
public:
    COemPDEV(void) :
        m_pfnDrvEndDoc(NULL),
        pBufStart(NULL),
        dwBufSize(0),
        cPalColors(0),
        hpalDefault(),
        prgbq(NULL),
        cbHeaderOffBits(0),
        bHeadersFilled(FALSE),
        bColorTable(FALSE)  
    {
        memset(&bmFileHeader, 0, sizeof(bmFileHeader));
        memset(&bmInfoHeader, 0, sizeof(bmInfoHeader));
    }

    virtual ~COemPDEV(void)
    {
    }

    void InitializeDDITable(DRVENABLEDATA* pded)
    {
        UINT   iDrvFn;
        UINT   cDrvFn = pded->c;
        PDRVFN pDrvFn = pded->pdrvfn;

        for (iDrvFn = 0; iDrvFn < cDrvFn; ++iDrvFn, ++pDrvFn)
        {
            if (pDrvFn->iFunc == INDEX_DrvEndDoc)
            {
                m_pfnDrvEndDoc = (PFN_DrvEndDoc)(pDrvFn->pfn);
            }
        }
    }

public:

    PFN_DrvEndDoc       m_pfnDrvEndDoc;     // Unidrv function to call back into from the DDI hook
    PBYTE               pBufStart;          // Pointer to start of buffer to hold the bitmap data
    DWORD               dwBufSize;          // Buffer size
    BITMAPFILEHEADER    bmFileHeader;       // BitmapFileHeader for each dump
    BITMAPINFOHEADER    bmInfoHeader;       // BitmapInfoHeader for each dump
    int                 cPalColors;         // Count of colors in palette.
    HPALETTE            hpalDefault;            // Default palette to pass to GDI.
    _Field_size_(cPalColors) RGBQUAD * prgbq; // Color table
    INT                 cbHeaderOffBits;    // Offset to bits in the file
    BOOL                bHeadersFilled;     // Flag to indicate if the header stuff has been filled
    BOOL                bColorTable;        // Flag to indicate if color table needs to be dumped

};

typedef COemPDEV* POEMPDEV;

BOOL bGrowBuffer(POEMPDEV, DWORD);      // Function to enlarge the buffer for holding the bitmap data
VOID vFreeBuffer(POEMPDEV);             // Function to free the buffer for holding the bitmap data
BOOL bFillColorTable(POEMPDEV);         // Function to fill the color table for the bitmap data