[Original] Implementation of font anti-aliasing display in VB

xiaoxiao2021-03-06  40

Overview In general, the font displayed in the Windows environment is serrated. "General Situation" is based on your use of any version of the Windows operating system, and does not open the "Smoottable Desk Font Edge" feature provided in Windows XP or later, and the application you use does not provide font anti-saw tooth function. . Many users complain that the fonts under Windows are too bad ("" "displayed fonts and printed effects"), so Microsoft starts providing CleartyPE functions in Windows XP. There is also a corresponding function in MacOS, and KDE under Linux can also provide similar functions. These effects are mostly implemented using techniques in the 3D category, such as ClearType is implemented by DirectX, while KDE is through OpenGL.

This article is committed to introducing a simple way to implement font anti-aliasing, we will use VB6 to implement this feature.

The principle and 3D anti-aliasing technology are similar, and the technology we introduce is achieved by amplifying rendering -> jitter reduction. Specifically, it is to be rendered with multiple times of the size of the figure that needs to be rendered, and then zoom it into the actual size, which can effectively avoid the generation of zigzag.

Implementation We will display a known string in a PictureBox (PDEST), and the font and font size are "Tahoma" and 20 (these should be set via PDST attributes): SDisPlay = "Implementation of font anti-aliasing display" in VB is as follows: establish another PictureBox (PFont), set its font size of 20 × 4 = 80. Use its Print method to print this string:

PFont.Print SDisPlay

Next, a GDI32 API is called, called Stretchblt, which is to zoom in size in the specified device scenario (DC) and copied to another device scene. The SetStretchBltMode API should be called to specify the zoom mode before using StretchBLT. The best quality zoom mode is stretch_halftone, we will use it. If you don't know the usage of these two APIs, please refer to MSDN.

SetStretchBltMode pDest.hDC, STRETCH_HALFTONEStretchBlt pDest.hDC, 0, 0, pDest.TextWidth (sDisplay), pDest.TextHeight (sDisplay), pFont.hDC, 0, 0, pFont.TextWidth (sDisplay) / 15, pFont.TextHeight (sDisplay ) / 15, VBSRCCOPY

Next (if there is no error), you should be able to see the result in PDEST. It should be noted that you'd better set the PDEST and PFONT's AutoRAW properties to true.

You can download the code of a font anti-saw tooth engine.

All rights reserved Hillinsilence retain all rights from this article. All unauthorized reprint is prohibited.

转载请注明原文地址:https://www.9cbs.com/read-47638.html

New Post(0)