Introduction to the transformation of world spaces to page spaces

Source: Internet
Author: User
Tags xform

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 |

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.