to yinx(yinx): 另一套叫逻辑坐标,也是以窗口客户区左上角为(0,0),x坐标水平向右增加,y坐标垂直向下增加,但逻辑坐标得单位长度于设备坐标的关系是由这个窗口的坐标映射方式决定的(mapping mode)。 这句好像有点问题,按我的理解,不仅逻辑坐标的长度于映射模式有关,而且坐标的方向也和隐身模式相关. 在文本模式:x坐标水平向右增加,y坐标垂直向下增加 其他的模式:x坐标水平向右增加,y坐标垂直向上增加这个问题也曾经困扰了我,这使我个人的理解,欢迎各位发表自己的意见
to HeroRose() "这句好像有点问题,按我的理解,不仅逻辑坐标的长度于映射模式有关,而且坐标的方向也和隐身模式相关." 这是我的一个bug
Thank you for your good and detail explanation! what about the following two: SetWindowExt(), SetViewportExt
SetWindowsExt()就是设置Window的Extent(广度) ...View...........View..... The Viewport and the Window The mapping mode defines how Windows maps logical coordinates that are specified in GDI functions to device coordinates, where the particular device coordinate system depends on the function you use to obtain the device context. To continue this discussion of the mapping mode, we need some additional terminology. The mapping mode is said to define the mapping of the "window" (logical coordinates) to the "viewport" (device coordinates). The use of these two terms is unfortunate. In other graphics interface systems, the viewport often implies a clipping region. And in Windows, the term "window" has a very specific meaning to describe the area that a program occupies on the screen. We'll have to put aside our preconceptions of these terms during this discussion. The viewport is specified in terms of device coordinates (pixels). Most often the viewport is the same as the client area, but it can also refer to whole-window coordinates or screen coordinates if you've obtained a device context from GetWindowDC or CreateDC. The point (0, 0) is the upper left corner of the client area (or the whole window or the screen). Values of x increase to the right, and values of y increase going down. The window is specified in terms of logical coordinates, which might be pixels, millimeters, inches, or any other unit you want. You specify logical window coordinates in the GDI drawing functions. But in a very real sense, the viewport and the window are just mathematical constructs. For all mapping modes, Windows translates window (logical) coordinates to viewport (device) coordinates by the use of two formulas, xViewExt xViewport = (xWindow - xWinOrg) × ________ + xViewOrg xWinExt yViewExt yViewport = (yWindow - yWinOrg) × ________ + yViewOrg yWinExtwhere (xWindow, yWindow) is a logical point to be translated and (xViewport, yViewport) is the translated point in device coordinates, most likely client-area coordinates. These formulas use two points that specify an "origin" of the window and the viewport. The point (xWinOrg, yWinOrg) is the window origin in logical coordinates; the point (xViewOrg, yViewOrg) is the viewport origin in device coordinates. By default, these two points are set to (0, 0), but you can change them. The formulas imply that the logical point (xWinOrg, yWinOrg) is always mapped to the device point (xViewOrg, yViewOrg). If the window and viewport origins are left at their default (0, 0) values, the formulas simplify to xViewExt xViewport = xWindow × ________ xWinExt yViewExt yViewport = yWindow × ________ yWinExtThe formulas also include two points that specify "extents": the point (xWinExt, yWinExt) is the window extent in logical coordinates; (xViewExt, yViewExt) is the viewport extent in device coordinates. In most mapping modes, the extents are implied by the mapping mode and cannot be changed. Each extent means nothing by itself, but the ratio of the viewport extent to the window extent is a scaling factor for converting logical units to device units. For example, when you set the MM_LOENGLISH mapping mode, Windows sets xViewExt to be a certain number of pixels and xWinExt to be the length in hundredths of an inch occupied by xViewExt pixels. The ratio gives you pixels per hundredths of an inch. The scaling factors are expressed as ratios of integers rather than floating point values for performance reasons. The extents can be negative. This implies that values on the logical x-axis don't necessarily have to increase to the right and that values on the logical y-axis don't necessarily have to increase going down. Windows can also translate from viewport (device) coordinates to window (logical) coordinates: xWinExt xWindow = (xViewport - xViewOrg) × ________ + xWinOrg xViewExt yWinExt yWindow = (yViewport - yViewOrg) × ________ + yWinOrg yViewExtWindows provides two functions that let you convert between device points to logical points in a program. The following function converts device points to logical points: DPtoLP (hdc, pPoints, iNumber) ;The variable pPoints is a pointer to an array of POINT structures, and iNumber is the number of points to be converted. For example, you'll find this function useful for converting the size of the client area obtained from GetClientRect (which is always in terms of device units) to logical coordinates: GetClientRect (hwnd, &rect) ; DPtoLP (hdc, (PPOINT) &rect, 2) ;This function converts logical points to device points: LPtoDP (hdc, pPoints, iNumber) ;
There are four functions!What you said is more obscure than what in
MSDN?
However,thank you all the same for giving help!!
分别是设置窗口坐标原点,设置视口坐标原点,设置窗口的x,y方向的幅度和
设置视口的x,y方向的幅度
设置视口的x,y方向的幅度
各是指什么?窗口是什么,窗口是什么?
setwindowext()窗口宽度
x坐标水平向右增加,y坐标垂直向下增加,x,y坐标的单位长度单位都是像素。
另一套叫逻辑坐标,也是以窗口客户区左上角为(0,0),x坐标水平向右增加,y坐标垂直向下增加,但逻辑坐标得单位长度于设备坐标的关系是由这个窗口的坐标映射方式决定的(mapping mode)。
SetWindowOrg(...,x,y,...)是把逻辑坐标做平移,使设备坐标点(0,0)映射到逻辑坐标点(x,y)[原来是映射到逻辑坐标点(0,0)的]SetViewPortOrg(...,x,y,...)也是把逻辑坐标做平移,使逻辑坐标点(0,0)映射到设备坐标点(x,y)[原来是映射到设备坐标点(0,0)]
困了!累了!
另一套叫逻辑坐标,也是以窗口客户区左上角为(0,0),x坐标水平向右增加,y坐标垂直向下增加,但逻辑坐标得单位长度于设备坐标的关系是由这个窗口的坐标映射方式决定的(mapping mode)。
这句好像有点问题,按我的理解,不仅逻辑坐标的长度于映射模式有关,而且坐标的方向也和隐身模式相关.
在文本模式:x坐标水平向右增加,y坐标垂直向下增加
其他的模式:x坐标水平向右增加,y坐标垂直向上增加这个问题也曾经困扰了我,这使我个人的理解,欢迎各位发表自己的意见
"这句好像有点问题,按我的理解,不仅逻辑坐标的长度于映射模式有关,而且坐标的方向也和隐身模式相关."
这是我的一个bug
what about the following two:
SetWindowExt(),
SetViewportExt
...View...........View.....
The Viewport and the Window
The mapping mode defines how Windows maps logical coordinates that are specified in GDI functions to device coordinates, where the particular device coordinate system depends on the function you use to obtain the device context. To continue this discussion of the mapping mode, we need some additional terminology. The mapping mode is said to define the mapping of the "window" (logical coordinates) to the "viewport" (device coordinates). The use of these two terms is unfortunate. In other graphics interface systems, the viewport often implies a clipping region. And in Windows, the term "window" has a very specific meaning to describe the area that a program occupies on the screen. We'll have to put aside our preconceptions of these terms during this discussion. The viewport is specified in terms of device coordinates (pixels). Most often the viewport is the same as the client area, but it can also refer to whole-window coordinates or screen coordinates if you've obtained a device context from GetWindowDC or CreateDC. The point (0, 0) is the upper left corner of the client area (or the whole window or the screen). Values of x increase to the right, and values of y increase going down. The window is specified in terms of logical coordinates, which might be pixels, millimeters, inches, or any other unit you want. You specify logical window coordinates in the GDI drawing functions. But in a very real sense, the viewport and the window are just mathematical constructs. For all mapping modes, Windows translates window (logical) coordinates to viewport (device) coordinates by the use of two formulas,
xViewExt
xViewport = (xWindow - xWinOrg) × ________ + xViewOrg
xWinExt
yViewExt
yViewport = (yWindow - yWinOrg) × ________ + yViewOrg
yWinExtwhere (xWindow, yWindow) is a logical point to be translated and (xViewport, yViewport) is the translated point in device coordinates, most likely client-area coordinates. These formulas use two points that specify an "origin" of the window and the viewport. The point (xWinOrg, yWinOrg) is the window origin in logical coordinates; the point (xViewOrg, yViewOrg) is the viewport origin in device coordinates. By default, these two points are set to (0, 0), but you can change them. The formulas imply that the logical point (xWinOrg, yWinOrg) is always mapped to the device point (xViewOrg, yViewOrg). If the window and viewport origins are left at their default (0, 0) values, the formulas simplify to
xViewExt
xViewport = xWindow × ________
xWinExt yViewExt
yViewport = yWindow × ________
yWinExtThe formulas also include two points that specify "extents": the point (xWinExt, yWinExt) is the window extent in logical coordinates; (xViewExt, yViewExt) is the viewport extent in device coordinates. In most mapping modes, the extents are implied by the mapping mode and cannot be changed. Each extent means nothing by itself, but the ratio of the viewport extent to the window extent is a scaling factor for converting logical units to device units. For example, when you set the MM_LOENGLISH mapping mode, Windows sets xViewExt to be a certain number of pixels and xWinExt to be the length in hundredths of an inch occupied by xViewExt pixels. The ratio gives you pixels per hundredths of an inch. The scaling factors are expressed as ratios of integers rather than floating point values for performance reasons. The extents can be negative. This implies that values on the logical x-axis don't necessarily have to increase to the right and that values on the logical y-axis don't necessarily have to increase going down. Windows can also translate from viewport (device) coordinates to window (logical) coordinates:
xWinExt
xWindow = (xViewport - xViewOrg) × ________ + xWinOrg
xViewExt yWinExt
yWindow = (yViewport - yViewOrg) × ________ + yWinOrg
yViewExtWindows provides two functions that let you convert between device points to logical points in a program. The following function converts device points to logical points:
DPtoLP (hdc, pPoints, iNumber) ;The variable pPoints is a pointer to an array of POINT structures, and iNumber is the number of points to be converted. For example, you'll find this function useful for converting the size of the client area obtained from GetClientRect (which is always in terms of device units) to logical coordinates:
GetClientRect (hwnd, &rect) ;
DPtoLP (hdc, (PPOINT) &rect, 2) ;This function converts logical points to device points:
LPtoDP (hdc, pPoints, iNumber) ;
譬如 pDC->lineto(xxxxxxx);