1、映射模式的设置
可以通过SetMapMode 和GetMapMode 两个函数来调用;
int SetMapMode(
HDC hdc, // handle of device context
int fnMapMode // new mapping mode 映射模式
);
设置当前的设备环境的映射模式
int GetMapMode(
HDC hdc // handle of device context
);
获取当前的设备环境的映射模式
窗口是对应逻辑坐标系上程序员设定的一个区域,视口是对应于实际输出设备上程序员设定的一个区域。
窗口区域的定义由SetWindowExtEx 函数完成
BOOL SetWindowExtEx(
HDC hdc, // handle of device context
int nXExtent, // new horizontal window extent 为以逻辑单位表示的新窗口区域高度
int nYExtent, // new vertical window extent
LPSIZE lpSize // original window extent
);
视口区域的定义由SetViewportExtEx函数完成
BOOL SetViewportExtEx(
HDC hdc, // handle of device context
int nXExtent, // new horizontal viewport extent 以物理设备单位表示的新视口区域高度
int nYExtent, // new vertical viewport extent
LPSIZE lpSize // original viewport extent
);
例如:
SetWindowExtEx(hdc,1,1,NULL);
SetViewportExtEx(hdc,10,10,NULL);
表示一个单位十个象素;Y轴向下,X轴向左
如果为SetWindowExtEx(hdc,-1,-1,NULL)则表示Y轴向上,X轴向右
视口的原点和窗口的原点可以通过SetWindowOrgEx和SetViewportOrtEx两个函数来设置
BOOL SetWindowOrgEx(
HDC hdc, // handle of device context
int X, // new x-coordinate of window origin窗口
int Y, // new y-coordinate of window origin
LPPOINT lpPoint
// address of structure receiving original origin 保存原来的坐标POINT结构地址
);
BOOL SetViewportOrgEx(
HDC hdc, // handle of device context
int X, // new x-coordinate of viewport origin视口
int Y, // new y-coordinate of viewport origin
LPPOINT lpPoint
// address of structure receiving original origin
);
本文详细介绍了Windows绘图中映射模式的设置方法,包括如何使用SetMapMode和GetMapMode函数来设定和获取映射模式。此外,还介绍了窗口区域与视口区域的概念及其设置函数SetWindowExtEx和SetViewportExtEx,并解释了如何通过SetWindowOrgEx和SetViewportOrgEx函数来设定窗口原点和视口原点。
1104

被折叠的 条评论
为什么被折叠?



