Effects of line output in different ing Modes

Source: Internet
Author: User
Tags one more line

During print preview: it is interesting.

1: The line with the width set to 1mm is the same as the line with the width set to 2mm.
The printer output is normal.
2: print preview: some lines of the same width are not displayed.
The printer output is normal.

A closer look is actually a display problem in the ing mode. Given that the ing mode is always a focal point
It is worth summarizing:

Start analysis:
Step 1: Write an example of the MM_TEXT mode. Print 6 vertical lines with the width increasing from 1.
Dc. SetMapMode (MM_TEXT );
For (int ii = 1; ii <= 6; ii ++)
{
CPen pen;
Pen. CreatePen (PS_SOLID, ii, RGB (255, 0 ));
CPen * pOldPen = dc. SelectObject (& pen );
Dc. MoveTo (xStart + xInterval * ii, 0 );
Dc. LineTo (xStart + xInterval * ii, xLineLen );
Dc. SelectObject (& pOldPen );
}
Of course, six lines of different widths are output.
Normal. The ing mode is measured in pixels.

Step 2: Simulate the print preview mode (1mm)
Long lloginch= 254;
Dc. SetMapMode (MM_ANISOTROPIC );
Dc. SetWindowExt (lLogInch, lLogInch );
Dc. SetViewportExt (dc. GetDeviceCaps (LOGPIXELSX), dc. GetDeviceCaps (LOGPIXELSY ));
Ing: 1 unit is 0.1mm.
Also use the above Code output.
Hey: Lines 1, 2, and 3 are as thick as 4, 5, and 6.
The actual printer output, the thickness is increasing, very normal.
Why?

Step 3: Is estimation accuracy a problem?
Look at the actual output pixels of each line in the new ing mode.
First, use long lX = dc. GetDeviceCaps (LOGPIXELSX );
Obtain the current display. An inch is equal to 96 pixels.
To calculate:
0.1mm -- "96/254 = 0.378
0.2mm -- "0.756
0.3mm -- "1.134
0.4mm -- "1.512
0.5mm -- "1.89
0.6mm -- "2.268

Well, after rounding, 1, 2, 3 are all 1 pixel, 4, 5, and 6 are both 2 pixels.
What about the actual printer? LX = 600.
You don't need to calculate it. The accuracy is high. Of course, it's okay to print it out.

Conclusion 1:
Due to the pixel precision problem of the display, when you use a Pen to draw, it will be rounded. If
The current ing mode is not suitable. Different inputs on the application end are displayed in the same way after rounding.
Solution: for example, in Excel, do not provide a small line width. For example, the minimum line width must be converted.
One pixel. For example: 1/0. 378 = 0.26.

Step 4: The above rules apply only to the Line drawing method of the Pen. You can also use FillRect or
FillSolidRect mode. In addition, the starting Image 2 is displayed.
Next, try FillSolidRect:

Long xStart = 100;
Long xLineLen = 100*10;
Long xInterval = 50;
For (int ii = 0; ii <= 5; ii ++)
{
CRect rc (xStart + xInterval * ii, 0, xStart + xInterval * ii + 1, xLineLen );
Dc. FillSolidRect (rc, RGB (255, 0, 0 ));
}
Result:
Only the last four lines are displayed.
Why? Why is it not rounded up?

Step 5: The rectangle may be rounded in and then calculated in width? Yes? Do a test first.
When printing, add one more line for testing:
TRACE (_ T ("% f, % f"), rc. left * 0.378, rc. right * 0.378 );
The output is as follows:
37.800000, 38.178000
56.700000, 57.456000
75.600000, 76.734000
94.500000, 96.012000
113.400000, 115.290000
132.300000, 134.568000
Suppose that the width is:
0 0 1 1 2 3
Compare the output results.


Related Article

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.