FIX Coordinates with windows DDK

【问题】用Microsoft Edge使用自己实现的虚拟打印机(Unidrv)打印页面到PDF,图片特别小,但是用IE打印就正常。

【分析】 Debug发现:用IE打印图片进OEMStretchBlt函数,但是用Edge打印图片进的是OEMPlgBlt函数,oemuni用的是目标的区域,而后者的目标区域是一个平行四边形,而且目标区域的类型是POINTFIX。维基一下,Fixed point是用整形表示浮点型,所以需要知道小数部分占几位,再查看DDK,是28.4,所以小数部分占4位,得到的这个值需要除以16,才能换算到整数部分。

维基:https://en.wikipedia.org/wiki/Fixed-point_arithmetic

DDK:FIX Coordinates

GraphicsDDIs use fractional coordinates that can specify a location on the devicesurface within one-sixteenth of a pixel. (On vector devices, the fractionalcoordinates are sixteen times more accurate than the device resolution.) Thefractional coordinates are represented as 32-bit numbers in signed 28.4 bit FIX notation. In this notation, the highest-order28 bits represent the integer part of the coordinate, and the lowest 4 bitsrepresent the fractional part. For example, 0x0000003C equals +3.7500, and0xFFFFFFE8 equals -1.5000.

FIXcoordinates represent control points for lines and Bezier curves. For certainobjects, such as rectangular clip regions, GDI uses signed 32-bit integers torepresent coordinates. Because coordinates are 28-bit quantities, the highest 5bits of an integer coordinate are either all cleared or all set.

【解决办法】

if (pco->iDComplexity==DC_RECT)
{
	//28.4 fix point
	rtlDes.left = LONG(pptfixDest[0].x / 16.0 + 0.5); 
	rtlDes.top = LONG(pptfixDest[0].y / 16.0 + 0.5);
	rtlDes.right = LONG(pptfixDest[1].x / 16.0 + 0.5);
	rtlDes.bottom = LONG(pptfixDest[2].y / 16.0 + 0.5);
}






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值