在固定分辨率下,可以把pbu转换成确定长度吗?比如厘米或英寸?

xisat 2003-07-11 03:06:42
是不是和显示器大小也有关系?
...全文
139 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
dotnba 2004-01-09
  • 打赏
  • 举报
回复
/*
函数:
gf_cmtopbu
功能:
将Centimeters转化成PBUs
参数:
dec adec_cm
boolean ab_axis True X-axis,False Y-axis
返回:
int li_rtn
对应:
1 cm = 0.3937 inch
1 inch = 2.54 cm
时间:
2004-01-08
*/

int li_rtn //返回值
long ll_dc //桌面dc
long ll_ppix //每英寸像素

ll_dc = GetDc(DC_SCREEN)

if ab_axis then
ll_ppix = GetDeviceCaps(ll_dc,LOGPIXELSX)
li_rtn = PixelsToUnits(Integer(adec_cm * ll_ppix / 2.54),XPixelsToUnits!)
Else
ll_ppix = GetDeviceCaps(ll_dc,LOGPIXELSY)
li_rtn = PixelsToUnits(Integer(adec_cm * ll_ppix / 2.54),YPixelsToUnits!)
End if


ReleaseDC(DC_SCREEN,ll_dc)

return li_rtn
dotnba 2004-01-08
  • 打赏
  • 举报
回复
//常量


//For GetDeviceCaps
constant uLong LOGPIXELSX = 88 //Logical pixels per inch in X
constant uLong LOGPIXELSY = 90 //Logical pixels per inch in Y
//For GetDC
constant uLong DC_SCREEN = 0 //Entire Screen

//外部函数

//Retrieves device-specific information for the specified device
Function uLong GetDeviceCaps(long hdc,long nIndex) Library "gdi32"
//Retrieves a handle to a display device context
FUNCTION ulong GetDC(ulong hwnd) LIBRARY "user32.dll"
//Releases a device context (DC), freeing it for use by other applications
FUNCTION ulong ReleaseDC(ulong hwnd,ulong hdc) LIBRARY "user32.dll"

/*
函数:
gf_pbutocm
功能:
将PBUs转化成Centimeters
参数:
int ai_pbu pbu长度值
boolean ab_axis True X,Flase Y
返回:
dec ldec_rtn
对应:
1 cm = 0.3937 inch
1 inch = 2.54 cm
时间:
2004-01-08
*/

dec{3} ldec_rtn //返回值
long ll_dc //桌面dc
long ll_ppix //每英寸像素
long ll_pixels //pbu对应的像素

ll_dc = GetDc(DC_SCREEN)

if ab_axis then
ll_ppix = GetDeviceCaps(ll_dc,LOGPIXELSX)
ll_pixels = UnitsToPixels(ai_pbu,XUnitsToPixels!)
Else
ll_ppix = GetDeviceCaps(ll_dc,LOGPIXELSY)
ll_pixels = UnitsToPixels(ai_pbu,YUnitsToPixels!)
End if

ldec_rtn = (ll_pixels * 2.54) / ll_ppix

ReleaseDC(DC_SCREEN,ll_dc)

return ldec_rtn
xisat 2003-08-08
  • 打赏
  • 举报
回复
陈年老贴了,翻出来,
看看现在有人回答么
flyerlxg 2003-07-12
  • 打赏
  • 举报
回复
我觉得就是转换成像素后,再转换成cm也存在问题,如果.28的显示器与.20的显示器,同样的像素其转换后的值(指CM)是一样的吗?这方面我没有去试过,不知道行不行。
xisat 2003-07-12
  • 打赏
  • 举报
回复
具体怎么做呢?能不能给个小小的例子.
竹风荷 2003-07-11
  • 打赏
  • 举报
回复
可以这样,用UnitsToPixels把pbu转换为像素,然后用像素进行转换
freeliu 2003-07-11
  • 打赏
  • 举报
回复
pbu和厘米有一定的对应关系,但是横向和纵向的对应关系是不一样的。你可以将标尺打开,就可以看到对应关系了。

1,075

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧