效果还不是很好.. 有些偏移.
两篇文章链接:c++GDI+发光子与发光边框画法
算法还能改进
public void Luminous(Graphics g, int Fuzzy, Rectangle Rect, string Text, Rectangle Textrect, Font Font, int FontColor, int ShadowColor)
{
Bitmap Bit1 = new Bitmap(Rect .Width , Rect .Height , System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics g1 = Graphics.FromImage(Bit1);
g1.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g1.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
g1.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.AssumeLinear;
Bitmap Bit2 = new Bitmap(Rect.Width / Fuzzy, Rect.Height / Fuzzy, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics g2 = Graphics.FromImage(Bit2);
g2.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g2.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
//布局
int cb = ShadowColor / 65536;
int cg = (ShadowColor - cb* 65536) / 256;
int cr = ShadowColor - (cb * 65536) - (cg * 256);
SolidBrush B = new SolidBrush (Color .FromArgb (255,cr,cg,cb));
GraphicsPath path = new GraphicsPath();
path.AddString(Text, Font.FontFamily, (int)(FontStyle.Bold), Font.Size, Textrect , new StringFormat());
g1.FillPath(B, path);
path.Dispose();
//绘制文字
Auxiliary_Console.ts1(Fuzzy.ToString());
g2.DrawImage(Bit1 ,0,0,Rect .Width / Fuzzy ,Rect .Height /Fuzzy );
g1.Clear(Color .FromArgb (0));
g1.DrawImage(Bit2, 0, 0, Rect.Width, Rect.Height);
g1.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
//发光字底图
GraphicsPath path1 = new GraphicsPath();
path1.AddString(Text, Font.FontFamily, (int)(FontStyle.Bold), Font.Size, Textrect, new StringFormat());
cb = FontColor / 65536;
cg = (FontColor - cb * 65536) / 256;
cr = FontColor - (cb * 65536) - (cg * 256);
B.Color = Color.FromArgb(255, cr, cg, cb);
g1.FillPath(B, path1);
path.Dispose();
//绘制文字
g.DrawImage(Bit1, Rect.X, Rect.Y );
g1.Dispose();
g2.Dispose();
Bit1.Dispose();
Bit2.Dispose();
B.Dispose();
}//写发光字