SetViewportOrgEx---GDI学习

来源:互联网 发布:创世纪 许文彪 知乎 编辑:程序博客网 时间:2024/04/28 06:41

The SetViewportOrgEx function specifies which device point maps to the window origin (0,0).

总是对这个系列的函数不太清楚,ViewPort(Device Point),WindowPort(Logic Point),这个函数将参数中指定的x,y(设备坐标),映射到Window Origin(0,0),也就是你实用GDI时其坐标原点现在在(x,y)而不是UpLeft。

BOOL SetViewportOrgEx(  HDC hdc,        // handle to device context  int X,          // new x-coordinate of viewport origin  int Y,          // new y-coordinate of viewport origin  LPPOINT lpPoint // original viewport origin);

Parameters

hdc
[in] Handle to the device context.
X
[in] Specifies the x-coordinate, in device units, of the new viewport origin.
Y
[in] Specifies the y-coordinate, in device units, of the new viewport origin.
lpPoint
[out] Pointer to a POINT structure that receives the previous viewport origin, in device coordinates. If lpPoint is NULL, this parameter is not used.

This function (along with SetViewportExtEx and SetWindowExtEx) helps define the mapping from the logical coordinate space (also known as a window) to the device coordinate space (the viewport).

这个函数与SetViewportExtEx and SetWindowExtEx一起使用使得逻辑坐标映射到相应的设备坐标SetViewportOrgEx specifies which device point maps to the logical point (0,0). It has the effect of shifting the axes so that the logical point (0,0) no longer refers to the upper-left corner.

//map the logical point (0,0) to the device point (xViewOrg, yViewOrg)SetViewportOrgEx ( hdc, xViewOrg, yViewOrg, NULL)

This is related to the SetWindowOrgEx function. Generally, you will use one function or the other, but not both. Regardless of your use of SetWindowOrgEx and SetViewportOrgEx, the device point (0,0) is always the upper-left corner

SetWindowOrgEx可以达到同样的作用,但是通常情况下只应该使用其中的一个(记住),注意:不管是使用SetWindowOrgEx还是SetViewportOrgEx,设备点(0,0)始终是在左上角的。

 

为了以后不在这里纠缠不清,以后都只用这个函数了,现在GDI中的(0,0)现在是(x,y)了

原创粉丝点击