📄 fallback.cpp
字号:
//ulLogPixelsX //Specifies the width resolution of the device in logical pixels per inch. //For printers, this member should be set to the printer's resolution in dpi. //For displays, this member must be set to 96. pGDIInfo->ulLogPixelsX = RoundToLong( PRINTRESIZER_FALLBACK_LOGPIXELS_X / dScale ); //ulLogPixelsY //Specifies the height resolution of the device in logical pixels per inch. //For printers, this member should be set to the printer's resolution in dpi. //For displays, this member must be set to 96. pGDIInfo->ulLogPixelsY = RoundToLong( PRINTRESIZER_FALLBACK_LOGPIXELS_Y / dScale ); //flTextCaps //Specifies a flag describing Windows 3.1 text capabilities. If the driver TC_SCROLLBLT flag is in this member, it indicates that the console should perform text scrolling by redrawing the entire screen, using the driver-supplied DrvTextOut <ddifncs_e78c3647-65af-427c-8153-0046e031e345.xml.asp> function rather than the DrvBitBlt <ddifncs_1314a0f2-0f0d-4b76-b060-207e332dafde.xml.asp> or DrvCopyBits <ddifncs_95bc17c2-b4ae-4883-8866-cd9dded1f30d.xml.asp> functions. The driver should set this flag if screen-to-screen bit-block transfers are slow. If this flag is not set, the driver is implicitly requesting that the console perform text scrolls through DrvBitBlt/DrvCopyBits. // NOTE: PRINTMIRROR DOES THIS AND ALSO COMMENTED OUT CALL TO RIGHT pGDIInfo->flTextCaps = 0; // GetDeviceCaps(hdc,TEXTCAPS) //ulDACRed, ulDACGreen, ulDACBlue //Specifies the display number of DAC bits for the specified color. pGDIInfo->ulDACRed = 0; pGDIInfo->ulDACGreen = 0; pGDIInfo->ulDACBlue = 0; //ulAspectX //Specifies the relative width of a device pixel, in the range of one to 1000. // NOTE: PRINTMIRROR USES CONSTANT TO RIGHT pGDIInfo->ulAspectX = PRINTRESIZER_FALLBACK_ASPECT_X; //ulAspectY //Specifies the relative height of a device pixel, in the range of one to 1000. // NOTE: PRINTMIRROR USES CONSTANT TO RIGHT pGDIInfo->ulAspectY = PRINTRESIZER_FALLBACK_ASPECT_Y; //ulAspectXY //Specifies the square root of the sum of the squares of ulAspectX and ulAspectY. // NOTE: PRINTMIRROR USES CONSTANT TO RIGHT pGDIInfo->ulAspectXY = PRINTRESIZER_FALLBACK_ASPECT_XY; //xStyleStep //Specifies the numerator of style advance for x-major lines, dx. For additional information, refer to the following Comments section and Styled Cosmetic Lines </library/en-us/graphics/hh/graphics/ddioview_7ded3a6e-abf5-41fd-84b2-039d483bd51c.xml.asp>. // NOTE: PRINTMIRROR USED CONSTANT "1" pGDIInfo->xStyleStep = 25; // = 1 //yStyleStep //Specifies the numerator of style advance for y-major lines, dy. For additional information, refer to the following Comments section and Styled Cosmetic Lines </library/en-us/graphics/hh/graphics/ddioview_7ded3a6e-abf5-41fd-84b2-039d483bd51c.xml.asp>. // NOTE: PRINTMIRROR USED CONSTANT "1" pGDIInfo->yStyleStep = 25; // = 1 //denStyleStep //Specifies the denominator of style advance, D. For additional information, refer to the following Comments section and Styled Cosmetic Lines </library/en-us/graphics/hh/graphics/ddioview_7ded3a6e-abf5-41fd-84b2-039d483bd51c.xml.asp>. // NOTE: PRINTMIRROR USES LOGPIXELS 0N X AXIS DIVIDED BY 25 HERE pGDIInfo->denStyleStep = pGDIInfo->ulLogPixelsX; // = pGDIInfo->ulLogPixelsX / 25 //ptlPhysOffset //Specifies a POINTL <grstrcts_bb79820f-05c8-42bf-a7a9-923b6fbc206e.xml.asp> structure that contains the size, in pixels, of the unwritable margin of a surface. pGDIInfo->ptlPhysOffset = ptlPhysOffset; //szlPhysSize //Specifies a SIZEL structure that contains the size, in pixels, of the entire surface, including unwritable margins. A SIZEL structure is identical to a SIZE <grstrcts_2697a459-d1f4-4617-8370-d51a3c79f609.xml.asp> structure. // NOTE: PRINTMIRROR USES THE COMMENTED CODE TO THE RIGHT pGDIInfo->szlPhysSize = szlPhysSize; //ulNumPalReg //Specifies the number of palette registers for an indexed device. //NOTE: PRINTMIRROR AND MSPLOT BOTH SET THIS TO 0 pGDIInfo->ulNumPalReg = 0; //ciDevice //Is a COLORINFO <grstrcts_1e247041-c753-4925-a86c-fbd246410a72.xml.asp> structure that defines the device's colors in CIE coordinate space. //NOTE: THESE CONSTANTS ARE FROM PRINTMIRROR pGDIInfo->ciDevice = g_ciDevice; //ulDevicePelsDPI //For printers, specifies the number of pixels (or dots, or nozzles) per inch if the pixels are laid out side by side without overlapping or space between. For example, if the size of a pixel is 0.001 inch, this value is equal to one-divided-by 0.001. If the member is zero, GDI halftoning calculates this number based on the assumption that all pixels are connected with no overlapping. //Because the physical dot size for most printers is larger than the measured dot size, GDI uses this value to approximate how many physical dots can be placed, based on the cell size (pattern size). A log regression is then performed to determine what is most linear; that is, where the dots should be placed for the best coverage to optimize the overlapped device pixels coverage (dot gain). //For displays, this member should be set to zero. // NOTE: PRINTMIRROR USES CODE COMMENTED TO RIGHT pGDIInfo->ulDevicePelsDPI = 0; // = pGDIInfo->ulLogPixelsX //ulPrimaryOrder //Specifies the bit order of the device's primary colors or plane numbers for the halftone output. This member can be one of the values listed in the following table. // NOTE: PRINTMIRROR USES THIS CONSTANT pGDIInfo->ulPrimaryOrder = PRIMARY_ORDER_ABC; //ulHTPatternSize //Specifies the size of the halftone pattern. The values ending with AxB_M are variations of the AxB patterns. In other words, SIZE_AxB and SIZE_AxB_M differ by which pixels are lit in an A x B pattern. This member can be one of the following values: // NOTE: PRINTMIRROR USES THIS CONSTANT pGDIInfo->ulHTPatternSize = HT_PATSIZE_16x16_M; //ulHTOutputFormat //Specifies the preferred output format for halftone. HT_FORMAT_4BPP uses only 8 full intensity colors while HT_FORMATP_IRGB uses all the 16 colors including the half-intensity colors. It is assumed that a 5 x 5 x 5 format (5 bits per color) is used for HT_FORMAT_16BPP. This member can be one of the following values: // NOTE: PRINTMIRROR USES THIS CONSTANT pGDIInfo->ulHTOutputFormat= HT_FORMAT_24BPP; //flHTFlags //Specifies a combination of flags describing the device. These flags are needed for halftoning. This member can be a combination of the following values: // NOTE: PRINTMIRROR AND MSPLOT USE THIS CONSTANT pGDIInfo->flHTFlags = HT_FLAG_HAS_BLACK_DYE; // NOTE: MSPLOT AND PRINTMIRROR SET THESE ALL TO 0 (HERE BY ZEROMEMORY ABOVE) //ulVRefresh //The video refresh rate for the current display mode. This is the value returned by the miniport driver for the refresh rate for the current mode. //The Display program in Control Panel displays the refresh rate contained in the ulVRefresh member. //ulBltAlignment //This member indicates the preferred x-alignment for bit block transfers to the device. A value of zero indicates that bit block transfers are accelerated; any other nonnegative number indicates that bit block transfers are not accelerated, and gives the preferred horizontal alignment as a pixel multiple. //This value is used by the system to determine the default alignment for window positions and is also used to set the initial full-drag default during setup. A value of zero indicates that full-drag should be on by default; any value other than zero indicates that full-drag should be off by default. //ulPanningHorzRes, ulPanningVertRes //Should be ignored by the driver and remain zero-initialized. //xPanningAlignment, yPanningAlignment //Should be ignored by the driver and remain zero-initialized. //cxHTPat, cyHTPat //Specify the width and height, respectively, in pixels, of the user-supplied halftone dither pattern. The value of cxHTPat must be in the range HT_USERPAT_CX_MIN to HT_USERPAT_CX_MAX, inclusive. The value of cyHTPat must be in the range HT_USERPAT_CY_MIN to HT_USERPAT_CY_MAX, inclusive. These constants are defined in winddi.h. See the following Comments section for more information. //pHTPatA, pHTPatB, pHTPatC //Point to the user-defined halftone dither patterns for primary colors A, B, and C, respectively, as defined by the PRIMARY_ORDER_XXX value in the ulPrimaryOrder member. Each dither pattern must be a valid two-dimensional byte array of size cxHTPat by cyHTPat. See the following Comments section for more information. //flShadeBlend //Specifies a set of flags that indicate the shading and blending capabilities of the device. Display drivers should ignore this member and should leave it set to zero. For printer drivers, the value that the driver places in this member is the value that GDI reports when an application calls GetDeviceCaps(hdc, SHADEBLENDCAPS). The GetDeviceCaps function is described in the Platform SDK documentation. //ulPhysicalPixelCharacteristics //Specifies the way that color fragments are configured to form pixels on the display device. The color fragments on the display device can be arranged in RGB order, or in BGR order, completely independent of the RGB ordering in the frame buffer </library/en-us/gloss/hh/gloss/glossary_10340c52-3b0e-434c-a5db-6870fd6cfac6.xml.asp>. The color fragments can be configured in horizontal stripes in which all of the fragments in one row are the same color. Alternatively, the color fragments can be configured in vertical stripes, in which all fragments in one column are the same color. Vertical striping is preferred, since it effectively provides three separate fragments in a row for each pixel, thereby giving greater horizontal subpixel resolution. //The ulPhysicalPixelCharacteristics member must be set to one of the values shown in the following table: //ulPhysicalPixelGamma //Specifies the gamma of the display device. This member should be set to either the gamma of the physical pixel, scaled by a factor of 1000, or to one of the following values. For example, a gamma value of 2.2 would be represented as 2200. bRetValue = TRUE; } return bRetValue;}BOOL Fallback_GetPaperGDIINFO( IN BOOL bLandscape, IN DWORD dmPaperSize, IN DWORD dmPaperWidth, IN DWORD dmPaperLength, IN const ULONG ulLogPixelsX, IN const ULONG ulLogPixelsY, IN const RECTL& rlMargins, // PAGE MARGINS IN MICROMETERS OUT ULONG& ulHorzSize, OUT ULONG& ulVertSize, OUT ULONG& ulHorzRes, OUT ULONG& ulVertRes, OUT POINTL& ptlPhysOffset, OUT SIZEL& szlPhysSize) { BOOL bRetValue = FALSE; SIZEL szlPaper; if ( ::Fallback_GetPaperSize(dmPaperSize, dmPaperWidth, dmPaperLength, rlMargins, szlPaper)) { SIZEL szlPrintable; szlPrintable.cx = szlPaper.cx - (rlMargins.left + rlMargins.right); szlPrintable.cy = szlPaper.cy - (rlMargins.top + rlMargins.bottom); ulHorzSize = - szlPrintable.cx; ulVertSize = - szlPrintable.cy; //ulHorzSize = szlPrintable.cx / 1000; //ulVertSize = szlPrintable.cy / 1000; ulHorzRes = RoundToLong( szlPrintable.cx * INCHES_PER_MICROMETER * ulLogPixelsX ); ulVertRes = RoundToLong( szlPrintable.cy * INCHES_PER_MICROMETER * ulLogPixelsY ); ptlPhysOffset.x = RoundToLong( rlMargins.left * INCHES_PER_MICROMETER * ulLogPixelsX ); ptlPhysOffset.y = RoundToLong( rlMargins.top * INCHES_PER_MICROMETER * ulLogPixelsY ); szlPhysSize.cx = RoundToLong( szlPaper.cx * INCHES_PER_MICROMETER * ulLogPixelsX ); szlPhysSize.cy = RoundToLong( szlPaper.cy * INCHES_PER_MICROMETER * ulLogPixelsY ); // ASSUMES 90 DEGREE LANDSCAPE ROTATION, AS IS SET IN Fallback DEVICE CAPABILITIES if (bLandscape) { ULONG ulHorzSizeTemp = ulHorzSize; ULONG ulVertSizeTemp = ulVertSize; ULONG ulHorzResTemp = ulHorzRes; ULONG ulVertResTemp = ulVertRes; POINTL ptlPhysOffsetTemp = ptlPhysOffset; SIZEL szlPhysSizeTemp = szlPhysSize; ulHorzSize = ulVertSizeTemp; ulVertSize = ulHorzSizeTemp; ulHorzRes = ulVertResTemp; ulVertRes = ulHorzResTemp; szlPhysSize.cx = szlPhysSizeTemp.cy; szlPhysSize.cy = szlPhysSizeTemp.cx; ptlPhysOffset.y = ptlPhysOffsetTemp.x; ptlPhysOffset.x = szlPhysSizeTemp.cy - (ulVertResTemp + ptlPhysOffsetTemp.y); } bRetValue = TRUE; } return bRetValue;}void Fallback_GetPaperMargins(OUT RECTL& rlMargins) { static const RECTL rlMarginsData = { RoundToLong(PRINTRESIZER_FALLBACK_PAGEMARGINS_LEFT * MICROMETERS_PER_INCH ), RoundToLong(PRINTRESIZER_FALLBACK_PAGEMARGINS_TOP * MICROMETERS_PER_INCH ), RoundToLong(PRINTRESIZER_FALLBACK_PAGEMARGINS_RIGHT * MICROMETERS_PER_INCH ), RoundToLong(PRINTRESIZER_FALLBACK_PAGEMARGINS_BOTTOM * MICROMETERS_PER_INCH ) }; rlMargins = rlMarginsData;}BOOL Fallback_GetPaperSize( IN DWORD dmPaperSize, IN DWORD dmPaperWidth, IN DWORD dmPaperLength, IN const RECTL& rlMargins, // MARGINS FOR PRINTABLE AREA FROM SIDES OF PAGE, MICROMETERS OUT SIZEL& out_szl) { BOOL bRetValue = FALSE; BOOL bHaveSize = FALSE; SIZEL szlPaper; if (dmPaperSize != 0 && dmPaperSize != DMPAPER_USER) { const ::PAPERSIZEINFO *ppsi = ::LookupPaperSize(dmPaperSize); if (ppsi != NULL) { szlPaper.cx = ppsi->dwWidth_Micrometers; szlPaper.cy = ppsi->dwHeight_Micrometers; bHaveSize = TRUE; } } else { szlPaper.cx = dmPaperWidth * 100; // DOCS - THESE IN TENTHS OF A MILLIMETER szlPaper.cy = dmPaperLength * 100; bHaveSize = TRUE; } if (bHaveSize) { bRetValue = Fallback_IsPaperSizeValid(szlPaper, rlMargins); if (bRetValue) { out_szl = szlPaper; } } return bRetValue;}// szlPaper IN MICROMETERSBOOL Fallback_IsPaperSizeValid(IN const SIZEL& szlPaper, IN const RECTL& rlMargins) { static const DWORD dwMinPageDim = RoundToLong( PRINTRESIZER_FALLBACK_MINUSERPAPER_DIMENSION * MICROMETERS_PER_INCH); static const DWORD dwMaxPageDim = RoundToLong( PRINTRESIZER_FALLBACK_MAXUSERPAPER_DIMENSION * MICROMETERS_PER_INCH); static const DWORD dwMinPrintableDim = RoundToLong( PRINTRESIZER_FALLBACK_MINUSERPAPERPRINTABLE_DIMENSION * MICROMETERS_PER_INCH); static const DWORD dwMaxPrintableDim = RoundToLong( PRINTRESIZER_FALLBACK_MAXUSERPAPERPRINTABLE_DIMENSION * MICROMETERS_PER_INCH); SIZEL szlPrintable; szlPrintable.cx = szlPaper.cx - ( rlMargins.left + rlMargins.right ); szlPrintable.cy = szlPaper.cy - ( rlMargins.top + rlMargins.bottom ); BOOL bRetValue = dwMinPageDim <= szlPaper.cx && szlPaper.cx <= dwMaxPageDim && dwMinPageDim <= szlPaper.cy && szlPaper.cy <= dwMaxPageDim && dwMinPrintableDim <= szlPaper.cx && szlPaper.cx <= dwMaxPrintableDim && dwMinPrintableDim <= szlPaper.cy && szlPaper.cy <= dwMaxPrintableDim; return bRetValue;}void Fallback_Merge(PDEVMODE pdmOut, PCDEVMODE pdmIn) { if (pdmIn->dmFields & DM_ORIENTATION) { switch (pdmIn->dmOrientation) { case DMORIENT_PORTRAIT: case DMORIENT_LANDSCAPE: pdmOut->dmOrientation = pdmIn->dmOrientation; pdmOut->dmFields |= DM_ORIENTATION; break; default: DEBUGMESSAGE( ("Inavlid dmOrientation = %ld", pdmIn->dmOrientation ) ); break; } } if (pdmIn->dmFields & DM_SCALE) { if (pdmIn->dmScale > 0 && pdmIn->dmScale <= PRINTRESIZER_FALLBACK_MAXSCALE) { pdmOut->dmScale = pdmIn->dmScale; pdmOut->dmFields |= DM_SCALE; } else { DEBUGMESSAGE( ("Invalid dmScale = %ld", pdmIn->dmScale) ); } } if (pdmIn->dmFields & DM_COPIES) { if (pdmIn->dmCopies <= PRINTRESIZER_FALLBACK_MAXCOPIES) { pdmOut->dmCopies = pdmIn->dmCopies; pdmOut->dmFields |= DM_COPIES; } else { DEBUGMESSAGE( ("Invalid dmCopies = %ld", pdmIn->dmCopies) ); } } if (pdmIn->dmFields & DM_PRINTQUALITY) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -