You might think that creating a special effect text with a soft shadow is completely different from generating a special effect text with an aperture, but the technology they use is exactly the same, but there is a slight change in the setting. In the soft shadow effect, I used GDI + in some interpolation mode to generate a vague text contour, when the bitmap plot plane amplification, the interpolation mode determines the original pixel should be how and the surrounding fusion. Low-quality interpolation is simply to transform a pixel into the same color block, high-quality interpolation such as high quality bilinear interpolation and high quality double three interpolation will consider the smooth and anti-aliasing like plain, I found the best bilinear interpolation mode.
This technique draws the text two times, drawing the aperture on a small bitmap at a time, it will be magnified in your chosen interpolation mode, and the actual text will be drawn on the plane another time. The bitmap used to generate the aperture must be proportional to the actual text, where I use 1/5, so the aperture text size is 1/5 of the actual text.
The steps are as follows:
Create a proportional bitmap that is smaller than the actual area of the plot, where I use 1/5;
Build a path to add the text you want to create the effect into the path;
Create a graphics with a bitmap of 1, and build a matrix that can reduce the output graph;
Use the aperture color you want, fill the text path, in order to adjust, with a very fine brush strokes the path;
Set the interpolation mode of the graphics that you want to output the bitmap to be high quality double linearity, enlarge the aperture bitmap proportionally to the target graphic;
Finally, on the target graphic, fill the text path by the actual size, which will produce the aperture effect shown below;
Second, the code description please use
void Ctexthaloeffectview::ondraw (cdc* pDC)
{
ctexthaloeffectdoc* PDoc = GetDocument ();
Assert_valid (PDOC);
if (!pdoc)
Return
Client area Size
CRect Clientrect;
GetClientRect (&clientrect);
CSize ClientSize (Clientrect.width (), Clientrect.height ());
using namespace Gdiplus;
Graphics g (PDC->M_HDC);
RECTF ClientRectangle (Clientrect.top,clientrect.left,clientrect.width (), Clientrect.height ());
G.fillrectangle (&solidbrush (color::black), clientrectangle);
Bitmap BM (CLIENTSIZE.CX/5,CLIENTSIZE.CY/5,&G);
Create a text path
GraphicsPath PTH;
Add the string in the chosen style.
int style = Fontstyleregular;
Pth. AddString (l "Text Aperture", -1,&fontfamily (L "Song Body"), Style,100,point (20,20), NULL);
Bitmap graphics
graphics* Bmpg = Graphics::fromimage (&BM);
Create a matrix that shrinks the drawing output by the fixed ratio.
Matrix mx (1.0f/5,0,0,1.0f/5,-(1.0F/5),-(1.0F/5));
Choose an appropriate smoothing mode for the halo.
Bmpg->setsmoothingmode (Smoothingmodeantialias);
Transform the Graphics object so this same half may is used for both and text output.
Transforms to 1/5 of the bitmap, magnified to resemble the actual text
Bmpg->settransform (&MX);
Using a suitable pen ...
Pen p (color::yellow,3);
Draw around the outline of the path
Bmpg->drawpath (&p,&pth);
And then fill in for good measure.
Bmpg->fillpath (&solidbrush (Color::yellow), &pth);
This just shifts the "effect a little bit so" the edge isn ' t cut out in the demonstration
Mobile 50,50
G.settransform (&matrix (1,0,0,1,50,50));
Setup the smoothing mode for path drawing
G.setsmoothingmode (Smoothingmodeantialias);
and the interpolation mode for the expansion of the Halo bitmap
G.setinterpolationmode (interpolationmodehighqualitybicubic);
Expand the halo making the edges nice and fuzzy.
G.drawimage (&BM,CLIENTRECTANGLE,0,0,BM. GetWidth (), BM. GetHeight (), unitpixel);
Redraw the original text
G.fillpath (&solidbrush (color::black), &pth);
And you are done.
}
Third, the effect chart
Figure One effect chart
Iv. description
In order to allow no GDI + friends to use conveniently, this time in GDI + directly included in the source code, the use of gdiplus.dll files directly to the $path can be copied.
Note: The author is familiar with C++/mfc, familiar with gdi/gdi+, English document translation, translation of documents, small system development, technical problems breakthrough, it technical training, etc.
Download source code: http://www.vckbase.com/code/downcode.asp?id=2677