Programming Windows (四)_ SetViewportOrgEx() 与 SetWindowportOrgEx()

来源:互联网 发布:大学生网络贷款的认识 编辑:程序博客网 时间:2024/05/23 00:11
SetWindowOrgEx
这个Window是看不见的,可以假想有这么一个Window,提供GDI画图函数以逻辑坐标来画图,这个坐标系也叫page space坐标系,有自定义原点与单位长度(逻辑单位,如0.1mm,从而可以与设备无关)


SetViewportOrgEx
物理设备坐标总是以左为原点,以像素为单位,x向右,y向下
viewport与之区别是原点可以由SetViewportOrgEx改变,以及大小可以由SetViewportExtEx改变,这个坐标系也叫device space坐标系,viewport也是看不到的,真的能看到的只有物理坐标系

SetWindowExtEx

设定page space的大小

SetViewportExtEx

设定device space的大小

四个函数完成其功能时均参考自己所在的坐标系,并且改变自己所在的坐标系

page space坐标系映射到device space坐标系
原点重合,大小关系为两个坐标系的大小关系:
(xViewport - xViewportOrg) / (xWindow - xWindowOrg) = xViewportExt / xWindowExt
一般用SetMapMode改变映射的大小关系以及page space  的坐标方向

device space坐标系映射到物理设备坐标系,都以像素为单位,所以只需考虑位移



for example:

SetMapMode (hdc, MM_ISOTROPIC) ;
SetWindowExtEx (hdc, 276, 72, NULL) ;
SetViewportExtEx (hdc, cxClient, cyClient, NULL) ;
SetWindowOrgEx (hdc, 138, 36, NULL) ;
SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;










If you change the viewport orgin to (xViewOrg, yViewOrg), the logical point(0, 0)will be mapped to the device point(xViewOrg, yViewOrg)




If you change the window origin to (xWinOrg, yWinOrg), the logical point(xWinOrg, yWinOrg) will be mapped to the device point(0,0)






Regardless of any changes you make to the window and viewport origins, the device point(0, 0) is always the upper left corner of the client area

原创粉丝点击