The so-called ing method is simply the coordinate arrangement method. The default ing method isMM_TEXT means that the X coordinates increase to the right, and the Y coordinates increase downward. () at the top left of the screen, each point in DC is a pixel on the screen. You may think this method is the best way to understand, but the relationship between a point and a pixel is normal on the screen, but it will be abnormal on the printer. Because our plot is in dot units and the resolution of the printer is much higher than that of the Monitor (800 DPI 800 points per inch), it looks very small in the printer shape. In this way, we need to increase the workload for printing another set of code. If each point corresponds to 0.1mm, the image on the screen will be the same size as the printed image.
PassInt CDC: SetMapMode (int nMapMode) can specify the ing mode, which can be:
MM_HIENGLISHEach vertex corresponds to 0.001 inch Each logical unit is converted to 0.001 inch. Positive x is to the right; positive y is up.
MM_HIMETRICEach vertex corresponds to 0.001mm Each logical unit is converted to 0.01 millimeter. Positive x is to the right; positive y is up.
MM_LOENGLISHEach vertex corresponds to 0.01 inch Each logical unit is converted to 0.01 inch. Positive x is to the right; positive y is up.
MM_LOMETRICEach vertex corresponds to 0.001mm Each logical unit is converted to 0.1 millimeter. Positive x is to the right; positive y is up.
MM_TEXTEach logical unit is converted to 1 device pixel. Positive x is to the right; positive y is down.
The default origins of the above mappings are located in the upper-left corner of the screen. DivisionAll values outside MM_TEXT increase to the right of X coordinates, and Y coordinates increase upwards, which is consistent with natural coordinates. Therefore, we need to pay attention to when negative coordinates should be used for plotting. And the above ing is proportional to the X-Y, that is, the same length in X, Y axis shows the length is the same.
Another ing method isMM_ANISOTROPICIn this way, you can specify different length-width ratios. You must call the ing method after setting thisCSize CDC: setshortwext (SIZE size SIZE) and CSize CDC: SetViewportExt (size SIZE size) to set the length/width ratio. The system determines the ratio of length to width based on the ratio of length to width set twice. The following code compares the ratio of length to width before and after ing:
OnDraw (CDC * pDC)
{
CRect rpc3 (400,200, 0 );
PDC-> FillSolidRect (rpc3, RGB (0, 0, 255 ));
PDC-> SetMapMode (MM_ANISOTROPIC );
CSize sizeO;
SizeO = pDC-> setjavaswext (5, 5 );
TRACE ("winExt % d", sizeO. cx, sizeO. cy );
SizeO = pDC-> SetViewportExt (5, 10 );
TRACE ("ViewExt % d", sizeO. cx, sizeO. cy );
CRect rcC (0, 0, 200,200 );
PDC-> FillSolidRect (rcC, RGB (0,128, 0 ));
}
The figure drawn after the above Code is mapped is a rectangle.
Finally, let's talk about the Origin (Viewport origin), you can call CPoint CDC: SetViewportOrg (POINT point POINT) to reset the origin location, which is relative to the coordinates. For example, if you set the origin point to (20, 20), then the original (0, 0) is changed to (-20,-20 ).