The transformation of the coordinate space and the world to page spaces
The coordinate space is a plane, in which the graph is positioned in the plane rectangular coordinates. The application uses coordinate space to scale, translate, cut, and mirror the output of the graphic. The following coordinate spaces are involved in Windows GDI
世界坐标空间(world space)
页面坐标空间(page space)
设备坐标空间(device space)
物理坐标空间(physical device space)
Transformation can change the size of the target, direction, shape, transformation can also transform the graphic object from one coordinate space to another space, and eventually in the physical devices such as screen, printer display.
I am now introducing a relatively small conversion of world spaces to Page spaces in programming. In the default GDI drawing mode there is no World space to page space conversion, only the application through SetGraphicsMode set graphics mode to Gm_ Advanced and call Setworldtransform to set the transformation parameters will have the World space to page space conversion.
Second, the world's space to page space conversion principle
1. Important structures and functions are as follows:
typedef struct _XFORM {
FLOAT eM11;
FLOAT eM12;
FLOAT eM21;
FLOAT eM22;
FLOAT eDx;
FLOAT eDy;
}XFORM, *PXFORM;
Matrix data for the transformation.
int SetGraphicsMode(
HDC hdc, // handle to device context
int iMode // graphics mode
);
Sets the graphics mode of the device environment context (DC), which can support world transformations when graphics mode is set to gm_advanced.
BOOL SetWorldTransform(
HDC hdc, // handle to device context
CONST XFORM *lpXform // transformation data
);
Sets the world transformation of the device environment context (DC).
BOOL CombineTransform(
LPXFORM lpxformResult, // combined transformation
CONST XFORM *lpxform1, // first transformation
CONST XFORM *lpxform2 // second transformation
);
The combined operation of the world transformation.
BOOL GetWorldTransform(
HDC hdc, // handle to device context
LPXFORM lpXform // transformation
);
Gets the world transformation of the device environment context (DC).
2. The transformation principle assumes that the coordinates in world space are (x,y), the transformed coordinates are (x ', Y '), and the transformation matrix data is:
FLOAT eM11;
FLOAT eM12;
FLOAT eM21;
FLOAT eM22;
FLOAT eDx;
FLOAT eDy;
The transformation calculation formula is as follows:
| eM11 eM12 0 |
|x'' y'' 1| = |x y 1| * | eM21 eM22 0 |
| eDx eDy 1 |