📄 winddi.h
字号:
#define HT_PATSIZE_MAX_INDEX HT_PATSIZE_USER
#define HT_PATSIZE_DEFAULT HT_PATSIZE_SUPERCELL_M
#define HT_USERPAT_CX_MIN 4
#define HT_USERPAT_CX_MAX 256
#define HT_USERPAT_CY_MIN 4
#define HT_USERPAT_CY_MAX 256
// Allowed values for GDIINFO.ulHTOutputFormat.
#define HT_FORMAT_1BPP 0
#define HT_FORMAT_4BPP 2
#define HT_FORMAT_4BPP_IRGB 3
#define HT_FORMAT_8BPP 4
#define HT_FORMAT_16BPP 5
#define HT_FORMAT_24BPP 6
#define HT_FORMAT_32BPP 7
// Allowed values for GDIINFO.flHTFlags.
#define HT_FLAG_SQUARE_DEVICE_PEL 0x00000001
#define HT_FLAG_HAS_BLACK_DYE 0x00000002
#define HT_FLAG_ADDITIVE_PRIMS 0x00000004
#define HT_FLAG_USE_8BPP_BITMASK 0x00000008
#define HT_FLAG_INK_HIGH_ABSORPTION 0x00000010
#define HT_FLAG_INK_ABSORPTION_INDICES 0x00000060
#define HT_FLAG_DO_DEVCLR_XFORM 0x00000080
#define HT_FLAG_OUTPUT_CMY 0x00000100
#define HT_FLAG_PRINT_DRAFT_MODE 0x00000200
#define HT_FLAG_INVERT_8BPP_BITMASK_IDX 0x00000400
#define HT_FLAG_8BPP_CMY332_MASK 0xFF000000
#define MAKE_CMYMASK_BYTE(c,m,y) ((BYTE)(((BYTE)(c) & 0x07) << 5) | \
(BYTE)(((BYTE)(m) & 0x07) << 2) | \
(BYTE)((BYTE)(y) & 0x03))
#define MAKE_CMY332_MASK(c,m,y) ((DWORD)(((DWORD)(c) & 0x07) << 29) | \
(DWORD)(((DWORD)(m) & 0x07) << 26) | \
(DWORD)(((DWORD)(y) & 0x03) << 24))
#define HT_FLAG_INK_ABSORPTION_IDX0 0x00000000
#define HT_FLAG_INK_ABSORPTION_IDX1 0x00000020
#define HT_FLAG_INK_ABSORPTION_IDX2 0x00000040
#define HT_FLAG_INK_ABSORPTION_IDX3 0x00000060
#define HT_FLAG_HIGHEST_INK_ABSORPTION (HT_FLAG_INK_HIGH_ABSORPTION | \
HT_FLAG_INK_ABSORPTION_IDX3)
#define HT_FLAG_HIGHER_INK_ABSORPTION (HT_FLAG_INK_HIGH_ABSORPTION | \
HT_FLAG_INK_ABSORPTION_IDX2)
#define HT_FLAG_HIGH_INK_ABSORPTION (HT_FLAG_INK_HIGH_ABSORPTION | \
HT_FLAG_INK_ABSORPTION_IDX1)
#define HT_FLAG_NORMAL_INK_ABSORPTION HT_FLAG_INK_ABSORPTION_IDX0
#define HT_FLAG_LOW_INK_ABSORPTION (HT_FLAG_INK_ABSORPTION_IDX1)
#define HT_FLAG_LOWER_INK_ABSORPTION (HT_FLAG_INK_ABSORPTION_IDX2)
#define HT_FLAG_LOWEST_INK_ABSORPTION (HT_FLAG_INK_ABSORPTION_IDX3)
// Setting/checking halftone 8bpp bitmask RGB mode
#define HT_BITMASKPALRGB (DWORD)'0BGR'
#define HT_SET_BITMASKPAL2RGB(pPal) (*((LPDWORD)(pPal)) = HT_BITMASKPALRGB)
#define HT_IS_BITMASKPALRGB(pPal) (*((LPDWORD)(pPal)) == (DWORD)0)
// Allowed values for GDIINFO.ulPhysicalPixelCharacteristics
#define PPC_DEFAULT 0x0
#define PPC_UNDEFINED 0x1
#define PPC_RGB_ORDER_VERTICAL_STRIPES 0x2
#define PPC_BGR_ORDER_VERTICAL_STRIPES 0x3
#define PPC_RGB_ORDER_HORIZONTAL_STRIPES 0x4
#define PPC_BGR_ORDER_HORIZONTAL_STRIPES 0x5
// GDIINFO.ulPhysicalPixelGamma should be set either to the scaled
// gamma (x1000) of the physical pixel or one of the following
// values. For example, a 2.2 gamma would be represented as 2200
#define PPG_DEFAULT 0
#define PPG_SRGB 1
//============================================================================
// HALFTONE INFORMATION
//============================================================================
//
// HT_FLAG_DO_DEVCLR_XFORM flag specified devices and/or drivers are required
// gdi halftone to do a device transform when ICM is off, the device transform
// take a input RGB value and map it to the device color space to produced
// perceived density same as input RGB color values. This flag only valid if
// it is a printer device surface and its format is 16bpp or 24bpp.
//
// ** If devices are additive and/or device surface is 1bpp, 4bpp or 8bpp, then
// gdi halftone will always performed device transform regardless the
// setting of HT_FLAG_DO_DEVCLR_XFORM flag.
//
// HT_FLAG_8BPP_CMY332_MASK - define the bit mask for 8-bpp format halftone
// palette, this palette only used if a HT_FORMAT_8BPP is specified in
// flHTOutputFormat and HT_FLAG_USE_8BPP_BITMASK bit is set in the flHTFlags.
// if HT_FLAG_USE_8BPP_BITMAP is not set then a standard NT4.0 8-bpp format is
// assumed. The format of 8BPP is set per PDEV, it cannot be changed after
// the pDEV is created.
//
// To set HT_FLAG_8BPP_CMY332_MASK, macro MAKE_CMY332_MASK() can be used. When
// specified, the bit mask cover total of 8 bits area which describe the
// highest of level of CYAN, MAGENTA and YELLOW primary color, the maximum of
// Cyan is 3 bits (7 levels), Magenta is 3 bits (7 levels) and Yellow is 2 bit
// (3 levels).
//
// CMYMask Meaning
// ======= =======
// 0x6F Cyan=3, Magenta=3, Yellow=3
// 0xFF Cyan=7, Magenta=7, Yellow=3
// 0x25 Cyan=1, Magenta=1, Yellow=1, is same as using CMY 4bpp
//
// SPECIAL
// CMYMask Meagning
// ======= =======
// 0x00 Gray scale 256 levels
// 0x01 5 Levels (0-4) each of Cyan, Magenta and yellow, 5^3=125 color
// 0x02 6 Levels (0-5) each of Cyan, Magenta and yellow, 6^3=216 color
//
// Any other invalid combinations (any of Cyan, Magenta, Yellow level bits is
// 0 (zero) then it will returned palette entries 0
//
// The Palette indics are arranged as CMY entries with CYAN at highest bit
// numbers and YELLOW at lowest bit number as shown below for palette indics
// bit's (8 bit) definition.
//
// Pallete Index BIT#: 7 6 5 4 3 2 1 0
// | | | | | |
// +---C---+ +---M---+ +-Y-+
// | | |
// | | 0x03
// | | +-- Yellow 0-3, Max=4 levels
// | 0x1c
// | +-- Magenta 0-7, Max=8 levels
// 0xe0
// +-- Cyan 0-7, Max=8 levels
//
//
// If a primray color level in an index is greater than the prmary color
// levels then it is eqaul to the maximum primary color level, for example
// if C=7 (0xe0), and Cyan level only 5 then level 6 and 7 are same as 5
//
// To retrieve the palette definition for 8bpp format, use
//
// LONG APIENTRY
// HT_Get8BPPMaskPalette(PPALETTEENTRY pPaletteEntry,
// BOOL Use8BPPMaskPal,
// BYTE CMYMask,
// USHORT RedGamma,
// USHORT GreenGamma,
// USHORT BlueGamma);
//
// pPaletteEntry - Pointer to the PALETTEENTRY, if NULL it return palette
// count needed,
//
// * See note below for the pPaletteEntry[0] special settings.
//
// Use8BPPmaskPal - FALSE if a NT4.0 standard 8bpp palette requested, FALSE
// if a CMYMask 8bpp mask palette is needed.
//
// CMYMask - CMY bit mask for CMY as defined above. This must be the
// same primary level as defined in GDIInfo.flHTFlags.
// It should be same as ((GDIInfo.flHTFlags >> 24) & 0xFF).
// The CMYMask also can be specified using predefined macro
// MAKS_CMYMASK_BYTE(cLevel, mLevel, yLevel)
//
// RedGamma - Red gamma if Use8BPPMaskPal is FALSE, Cyan gamma
// if Use8BPPMaskPal is TRUE
//
// GreenGamma - Green gamma if Use8BPPMaskPal is FALSE, Magenta gamma
// if Use8BPPMaskPal is TRUE
//
// BlueGamma - Blue gamma if Use8BPPMaskPal is FALSE, Yellow gamma
// if Use8BPPMaskPal is TRUE
//
//
// ***************************************************************************
// * SPECIAL NOTE for Windows NT version later than Windows 2000 Release *
// ***************************************************************************
// Current version of Window NT (Post Windows 2000) will Overloading the
// pPaletteEntry in HT_Get8BPPMaskPalette(DoUseCMYMask) API to returned a
// inverted indices palette based on additive palette entries composition.
// Because Windows GDI ROP assume index 0 always black and last index always
// white without checking the palette entries. (Indices based ROPs rather color
// based) This cause many ROPS got wrong result which has inverted output.
//
// To correct this GDI ROPs behavior, the POST windows 2000 version of GDI
// Halftone will supports a special CMY_INVERTED format. All new drivers should
// use this CMY_INVERTED method for future compabilities
//
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @ Following Steps are required for ALL POST Windows 2000 Drivers when @
// @ using Window GDI Halftone 8bpp CMY332 Mask mode @
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//
// 1. Must set HT_FLAG_INVERT_8BPP_BITMASK_IDX flags
//
// 2. Must set pPaleteEntry[0] when calling HT_Get8BPPMaskPalette() with
//
// pPaletteEntry[0].peRed = 'R';
// pPaletteEntry[0].peGreen = 'G';
// pPaletteEntry[0].peBlue = 'B';
// pPaletteEntry[0].peFlags = '0';
//
// The caller can use following supplied macro to set this for future
// compabilities
//
// HT_SET_BITMASKPAL2RGB(pPaletteEntry)
//
// where pPaletteEntry is the pointer to the PALETTEENTRY that passed to
// the HT_GET8BPPMaskPalette() fucntion call
//
// 3. Must Check the return Palette from HT_Get8BPPMaskPalette() using
// following Macro
//
// HT_IS_BITMASKPALRGB(pPaletteEntry)
//
// where pPaletteEntry is the pointer to the PALETTEENTRY that passed to the
// HT_GET8BPPMaskPalette() fucntion call,
//
// If this macro return FALSE then the current version of GDI HALFTONE does
// NOT support the CMY_INVERTED 8bpp bitmaask mode and it only supports CMY
// mode.
//
// If this macro return TRUE then the GDI HALFTONE DOES support the
// CMY_INVERTED 8bpp bitmaask mode and the caller must using a translation
// table to obtain final halftone surface bitmap 8bpp indices ink levels.
//
// 4. Behavior changes for GDI halftone that supports 8bpp CMY_INVERTED bitmask
// mode, following is a list of changes of CMYMask mode passed to
// the HT_Get8BPPMaskPalette()
//
// CMYMask CMY Mode Indices CMY_INVERTED Mode Indices
// ======= ========================= =============================
// 0 0: WHITE 0: BLACK
// 1-254: Light->Dark Gray 1-254: Dark->Light Gray
// 255: BLACK 255: WHITE
// -------------------------------------------------------------------
// 1 0: WHITE 0-65: BLACK
// 1-123: 5^3 CMY color 66-188: 5^3 RGB color
// 124-255: BLACK 189-255: WHITE
// 127-128: Duplicate for XOR ROP
// (CMY Levels 2:2:2)
// -------------------------------------------------------------------
// 2 0: WHITE 0-20: BLACK
// 1-214: 6^3 CMY color 21-234: 6^3 RGB color
// 215-255: BLACK 235-255: WHITE
// -------------------------------------------------------------------
// 3-255* 0: WHITE 0: BLACK
// 1-254: CMY Color BitMask 1-254: Centered CxMxY BitMask*
// 255: BLACK 255: WHITE
// ===================================================================
//
// * For CMYMask mode 3-255, the valid combination must NOT have any
// of Cyan, Magenta or Yellow ink level equal to 0.
//
// * The reason for CMY_INVERTED mode that pading BLACK and WHITE entires
// at both end and have all other color in the middle is to make sure
// all 256 color palette entries are even distributed so that GDI ROPs
// (raster operation) will work more correctly. This is because GDI ROPs
// are based on the indices not color
//
// * The CMY_INVERTED Mode has all non-black, non white indices centered
// and even distributed within the total 256 palette indices. For
// example; if a CMY=333 levels then it has total 3x3x3=27 indices,
// these 27 indices will be centered by packing 114 black indices at
// begining and packing 114 white indices at end to ensure that ROP
// will be correct rendered.
//
// See following sample function of for how to generate these ink levels
// and Windows 2000 CMY332 Index translation table
//
//
// 5. For CMYMask index mode 0 to 255, the caller can use following sample
// function to genrate INKLEVELS translation table
//
// The follwing structure and tables are examples of how to translate 8bpp
// bitmask halftone bitmap indices to ink levels
//
// typedef struct _INKLEVELS {
// BYTE Cyan; // Cyan level from 0 to max
// BYTE Magenta; // Magenta level from 0 to max
// BYTE Yellow; // Yellow level from 0 to max
// BYTE CMY332Idx; // Original windows 2000 CMY332 Index
// } INKLEVELS, *PINKLEVELS;
//
// To Compute a 8bpp translate table of INKLEVELS, following sample
// function show how to genrate a INKLEVELS translate table for a valid
// CMYMask range from 0 to 255. It can be use to generate either Windows
// 2000 CMY Mode or new Post Windows 2000's CMY_INVERTED mode translation
// table. It also generate a windows 2000 CMY Mode CMY332Idx so caller
// can map CMY_INVERTED new indices to old index for current existing
// indices processing function.
//
// Example Function that generate translate table for CMYMask 0 to 255,
// the pInkLevels must pointed to a valid memory location of 256 INKLEVELS
// entries, if return value is TRUE then it can be used to trnaslate 8bpp
// indices to ink levels or mapp to the older CMY332 style indices.
//
//
// BOOL
// GenerateInkLevels(
// PINKLEVELS pInkLevels, // Pointer to 256 INKLEVELS table
// BYTE CMYMask, // CMYMask mode
// BOOL CMYInverted // TRUE for CMY_INVERTED mode
// )
// {
// PINKLEVELS pILDup;
// PINKLEVELS pILEnd;
// INKLEVELS InkLevels;
// INT Count;
// INT IdxInc;
// INT cC;
// INT cM;
// INT cY;
// INT xC;
// INT xM;
// INT xY;
// INT iC;
// INT iM;
// INT iY;
// INT mC;
// INT mM;
//
//
// switch (CMYMask) {
//
// case 0:
//
// cC =
// cM =
// xC =
// xM = 0;
// cY =
// xY = 255;
// break;
//
// case 1:
// case 2:
//
// cC =
// cM =
// cY =
// xC =
// xM =
// xY = 3 + (INT)CMYMask;
// break;
//
// default:
//
// cC = (INT)((CMYMask >> 5) & 0x07);
// cM = (INT)((CMYMask >> 2) & 0x07);
// cY = (INT)( CMYMask & 0x03);
// xC = 7;
// xM = 7;
// xY = 3;
// break;
// }
//
// Count = (cC + 1) * (cM + 1) * (cY + 1);
//
// if ((Count < 1) || (Count > 256)) {
//
// return(FALSE);
// }
//
// InkLevels.Cyan =
// InkLevels.Magenta =
// InkLevels.Yellow =
// InkLevels.CMY332Idx = 0;
// mC = (xM + 1) * (xY + 1);
// mM = xY + 1;
// pILDup = NULL;
//
// if (CMYInverted) {
//
// //
// // Move the pInkLevels to the first entry which center around
// // 256 table entries, if we skip any then all entries skipped
// // will be white (CMY levels all zeros). Because this is
// // CMY_INVERTED so entries start from back of the table and
// // moving backward to the begining of the table
// //
//
// pILEnd = pInkLevels - 1;
// IdxInc = ((256 - Count - (Count & 0x01)) / 2);
// pInkLevels += 255;
//
// while (IdxInc--) {
//
// *pInkLevels-- = InkLevels;
// }
//
// if (Count & 0x01) {
//
// //
// // If we have odd number of entries then we need to
// // duplicate the center one for correct XOR ROP to
// // operated correctly. The pILDup will always be index
// // 127, the duplication are indices 127, 128
// //
//
// pILDup = pInkLevels - (Count / 2) - 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -