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

📄 graphicsdriverentrypoints.cpp

📁 虚拟打印机
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	 return TRUE;}VOID CALLBACK DrvDisableDriver(VOID) {	// NOTHN}BOOL CALLBACK DrvStrokePath(	SURFOBJ   *pso,	PATHOBJ   *ppo,	CLIPOBJ   *pco,	XFORMOBJ  *pxo,	BRUSHOBJ  *pbo,	POINTL    *pptlBrushOrg,	LINEATTRS *plineattrs,	MIX        mix	) {     return TRUE;}BOOL CALLBACK DrvCopyBits(	SURFOBJ  *psoDest,	SURFOBJ  *psoSrc,	CLIPOBJ  *pco,	XLATEOBJ *pxlo,	RECTL    *prclDest,	POINTL   *pptlSrc	) {	int k = 0; // diff from DrvRealizeBrush	++k;	return TRUE;}BOOL CALLBACK DrvTextOut(	SURFOBJ  *pso,	STROBJ   *pstro,	FONTOBJ  *pfo,	CLIPOBJ  *pco,	RECTL    *prclExtra,	RECTL    *prclOpaque,	BRUSHOBJ *pboFore,	BRUSHOBJ *pboOpaque,	POINTL   *pptlOrg,	MIX       mix	) {	int k = 0; // diff from DrvStrokeAndFillPath	++k;	return TRUE;}BOOL CALLBACK DrvStartDoc(SURFOBJ *pso, LPWSTR pwszDocName, DWORD dwJobId) {	return TRUE;}BOOL  CALLBACK DrvEndDoc(SURFOBJ *pso, FLONG fl) {	return TRUE;}BOOL  CALLBACK DrvStartPage(SURFOBJ *pso) {	int k = 0; // diff from DrvSendPage	++k;     return TRUE;}BOOL  CALLBACK DrvSendPage(SURFOBJ *pso) {	// ++ pPDEV->Pages;	return TRUE;}// *********************************************************************************// ADD SOME EXTRA FOR NOW, DON'T KNOW WHICH ARE NEEDEDBOOL CALLBACK DrvRealizeBrush(BRUSHOBJ *pbo,SURFOBJ  *psoTarget,SURFOBJ  *psoPattern,SURFOBJ  *psoMask,XLATEOBJ *pxlo,ULONG    iHatch){     return TRUE;}BOOL CALLBACK DrvFillPath(SURFOBJ  *pso,PATHOBJ  *ppo,CLIPOBJ  *pco,BRUSHOBJ *pbo,POINTL   *pptlBrushOrg,MIX       mix,FLONG     flOptions){     return TRUE;}BOOL CALLBACK DrvStrokeAndFillPath(SURFOBJ   *pso,PATHOBJ   *ppo,CLIPOBJ   *pco,XFORMOBJ  *pxo,BRUSHOBJ  *pboStroke,LINEATTRS *plineattrs,BRUSHOBJ  *pboFill,POINTL    *pptlBrushOrg,MIX        mixFill,FLONG      flOptions){     return TRUE;}BOOL CALLBACK DrvPaint(SURFOBJ  *pso,CLIPOBJ  *pco,BRUSHOBJ *pbo,POINTL   *pptlBrushOrg,MIX       mix){     return TRUE;}BOOL CALLBACK DrvLineTo(SURFOBJ   *pso,CLIPOBJ   *pco,BRUSHOBJ  *pbo,LONG       x1,LONG       y1,LONG       x2,LONG       y2,RECTL     *prclBounds,MIX        mix){     return TRUE;}HBITMAP CALLBACK DrvCreateDeviceBitmap(        DHPDEV  dhpdev,        SIZEL  sizl,        ULONG  iFormat        ){     return 0;}VOID CALLBACK DrvDeleteDeviceBitmap(        DHSURF  dhsurf        ){}BOOL CALLBACK DrvBitBlt(SURFOBJ  *psoTrg,SURFOBJ  *psoSrc,SURFOBJ  *psoMask,CLIPOBJ  *pco,XLATEOBJ *pxlo,RECTL    *prclTrg,POINTL   *pptlSrc,POINTL   *pptlMask,BRUSHOBJ *pbo,POINTL   *pptlBrush,ROP4      rop4){     return TRUE;}BOOL CALLBACK DrvStretchBlt(SURFOBJ * psoDest, SURFOBJ * psoSrc,        SURFOBJ * psoMask, CLIPOBJ * pco,        XLATEOBJ * pxlo, COLORADJUSTMENT * pca,        POINTL * pptlHTOrg, RECTL * prclDest,        RECTL * prclSrc, POINTL * pptlMask,        ULONG iMode){     return TRUE;}BOOL CALLBACK DrvStretchBltROP( SURFOBJ  *pTargetSurfObj, SURFOBJ   *pSourceSurfObj,        SURFOBJ                 *pMaskSurfObj, CLIPOBJ   *pClipObj,        XLATEOBJ                *pXlateObj, COLORADJUSTMENT    *pColorAdjustment,        POINTL                  *pHalfToneBrushOriginPointl, RECTL     *pTargetRectl,        RECTL                   *pSourceRectl, POINTL     *pMaskOffsetPointl,        ULONG                   mode, BRUSHOBJ    *pBrushObj,        ROP4                    rop4 //  some  places   this   also  referred  as  mix.        ){     return TRUE;}ULONG CALLBACKDrvEscape(SURFOBJ *pso,        ULONG    iEsc,        ULONG    cjIn,        PVOID    pvIn,        ULONG    cjOut,        PVOID    pvOut){	int k = 0; // diff from DrvDrawEscape	++k;     return 0;}ULONG CALLBACK DrvDrawEscape(SURFOBJ *pso,ULONG    iEsc,CLIPOBJ *pco,RECTL   *prcl,ULONG    cjIn,PVOID    pvIn){     return 0;}// *********************************************************************************// PRIVATE ROUTINESstatic void SetDEVINFO(PDEVINFO pDevInfo, DWORD dwcBuff) {	pDevInfo->iDitherFormat = BMF_24BPP;	pDevInfo->hpalDefault = EngCreatePalette(PAL_BGR, 0, 0, 0, 0, 0);	// ADD SOME STUFF, DON'T KNOW WHICH I ACTUALLY NEED	pDevInfo->flGraphicsCaps = 		GCAPS_ALTERNATEFILL		|		GCAPS_HORIZSTRIKE		|		GCAPS_VERTSTRIKE		|		GCAPS_VECTORFONT		| 		GCAPS_HALFTONE			| 		GCAPS_OPAQUERECT		|		GCAPS_BEZIERS			|		GCAPS_WINDINGFILL;}static BOOL GetGDIINFOFromTarget(PGDIINFO pGDIInfo, PCDEVMODE pdmTargetPrinter) {	BOOL bRetValue = FALSE;	::ZeroMemory(pGDIInfo, sizeof(*pGDIInfo));	HDC hdc = ::CreateDC(pdmTargetPrinter, TRUE);	if (hdc != NULL) {		//ulVersion 		//Specifies the driver version number. The byte ordering of ulVersion has the following form. 		// NOTE:  PRINTMIRROR DOES COMMENTED CODE TO RIGHT		pGDIInfo->ulVersion = PRINTRESIZER_GDIINFO_VERSION;	// = GetDeviceCaps(hdc , DRIVERVERSION) ;		//ulTechnology 		//Specifies the device technology. This member can be one of the values listed in the following table. 		// NOTE:  PRINTMIRROR DOES THIS		pGDIInfo->ulTechnology = GetDeviceCaps(hdc , TECHNOLOGY); // = DT_RASPRINTER;		//ulHorzSize 		//Specifies the width of the physical surface. A positive value indicates that the width is in units of millimeters, while a negative value denotes that the width is in units of micrometers. 		// NOTE:  VERSION COMMENTED OUT WAS TOO INACCURATE.  INSTEAD RETURN IN MICROMETERS USING 		//		  CALCULATED USING LOGPIXELS AND PHYSICAL SURFACE SIZE IN DEVICE UNITS		//pGDIInfo->ulHorzSize = GetDeviceCaps(hdc , HORZSIZE);		pGDIInfo->ulHorzSize = - RoundToLong( (GetDeviceCaps(hdc, HORZRES) * MICROMETERS_PER_INCH) / GetDeviceCaps(hdc , LOGPIXELSX) );		//ulVertSize 		//Specifies the height of the physical surface. A positive value indicates that the height is in units of millimeters, while a negative value denotes that the height is in units of micrometers. 		// NOTE:  VERSION COMMENTED OUT WAS TOO INACCURATE.  INSTEAD RETURN IN MICROMETERS USING 		//		  CALCULATED USING LOGPIXELS AND PHYSICAL SURFACE SIZE IN DEVICE UNITS		//pGDIInfo->ulVertSize = GetDeviceCaps(hdc , VERTSIZE);		pGDIInfo->ulVertSize = - RoundToLong( (GetDeviceCaps(hdc, VERTRES) * MICROMETERS_PER_INCH) / GetDeviceCaps(hdc , LOGPIXELSY) );		//ulHorzRes 		//Specifies the width in pixels of the physical surface (display devices), or of the printable surface (printers). 		pGDIInfo->ulHorzRes  = GetDeviceCaps(hdc , HORZRES);		//ulVertRes 		//Specifies the height in pixels of the physical surface (display devices), or of the printable surface (printers). 		pGDIInfo->ulVertRes  = GetDeviceCaps(hdc , VERTRES);		//cBitsPixel 		//Specifies the number of adjacent bits in each color plane. The total number of bits per pixel is the product of cBitsPixel and cPlanes. 		pGDIInfo->cBitsPixel = GetDeviceCaps(hdc , BITSPIXEL);		//cPlanes 		//Specifies the number of color planes. 		pGDIInfo->cPlanes    = GetDeviceCaps(hdc , PLANES);		//ulNumColors 		//For palettized devices, ulNumColors specifies the number of entries in the default color palette. For nonpalettized devices (which do not include printers), ulNumColors is set to -1. 		// NOTE:  PRINTMIRROR DID NOT INCLUDE "IF" BLOCK THAT FOLLOWS ASSIGNMENT		pGDIInfo->ulNumColors =  GetDeviceCaps(hdc , NUMCOLORS);		if (pGDIInfo->ulNumColors == 1) {	//  THIS ISN'T IN PRINTMIRROR			pGDIInfo->ulNumColors = 8;		//  6/24 "8" SEEMS A MORE REASONABLE VALUE FOR A PRINTER THAN "256"		}		//flRaster 		//Is reserved and must be left set to zero. 		pGDIInfo->flRaster     = 0;  // RESERVED AND MUST BE 0		//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 = GetDeviceCaps(hdc , LOGPIXELSX);		//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 = GetDeviceCaps(hdc , LOGPIXELSY);		//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    = GetDeviceCaps(hdc , ASPECTX);		// = 10		//ulAspectY 		//Specifies the relative height of a device pixel, in the range of one to 1000. 		// NOTE:  PRINTMIRROR USES CONSTANT TO RIGHT		pGDIInfo->ulAspectY    = GetDeviceCaps(hdc , ASPECTY);		// = 10		//ulAspectXY 		//Specifies the square root of the sum of the squares of ulAspectX and ulAspectY. 		// NOTE:  PRINTMIRROR USES CONSTANT TO RIGHT		pGDIInfo->ulAspectXY   = GetDeviceCaps(hdc , ASPECTXY);		// 14		//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.x = GetDeviceCaps(hdc , PHYSICALOFFSETX);		pGDIInfo->ptlPhysOffset.y = GetDeviceCaps(hdc , PHYSICALOFFSETY);		//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.cx = GetDeviceCaps(hdc, PHYSICALWIDTH); // =  pGDIInfo->ulHorzRes + 2 * GetDeviceCaps(hdc , PHYSICALOFFSETX);		pGDIInfo->szlPhysSize.cy = GetDeviceCaps(hdc, PHYSICALHEIGHT); // = pGDIInfo->ulVertRes + 2 * GetDeviceCaps(hdc , PHYSICALOFFSETY);		//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. 		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.		::DeleteDC(hdc);		bRetValue = TRUE;	}	return bRetValue;}

⌨️ 快捷键说明

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