发信人: redfox (Z掉了几乎所有的版...), 信区: BorlandDev
标 题: Delphi编程 -- 13.3 打印机的分辨率问题
发信站: 哈工大紫丁香 (2000年09月01日17:31:43 星期五), 站内信件
打印机的分辨率问题?
Printer Resolution ?
问:
I want to know, wich way I have to program, so every print is equal.
No
matter what resolution
of the printer (300 or 600 dpi).
Since now I program: TextOut(DC, 150, 150...) on a 300 dpi printer.
But on
600 dpi, everything
looks a bit strange, (small).
What Objects can I use to print corectly??
答:
I get the printer resolution (and unprintable are if desired) and
then specify coordinates using decimal inches * resulution e.g.
x = trunc(1.5 * ResX) at 300 dpi will begin at 360 * 1.5 or 540 pixels.
Get Resolution and unprintable
ResX := GetDeviceCaps(ACanvas.Handle,LOGPIXELSX);
ResY := GetDeviceCaps(ACanvas.Handle,LOGPIXELSY);
pOffsetX := GetDeviceCaps(ACanvas.Handle,PHYSICALOFFSETX);
pOffsetY := GetDeviceCaps(ACanvas.Handle,PHYSICALOFFSETY);
print something
Printer.Canvas.TextOut(trunc(1.5 * ResX)-pOffsetX,
trunc(2.5 * ResY)-pOffsetY,'Hello');
This is nice when printing data on an existing paper form as you can
just measure it up in decimal inches.
--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.227.107]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:5.024毫秒