zoukankan      html  css  js  c++  java
  • 字体辉光效果

            /// <summary>
            /// 字体辉光效果
            /// </summary>
            /// <param name="text">要处理的文字</param>
            /// <param name="font">字体样式</param>
            /// <param name="fontColor">文字颜色</param>
            /// <param name="effectColor">辉光颜色</param>
            /// <param name="scope">范围</param>
            /// <returns></returns>
            public static Image ImageLightEffect(string text, Font font, Color fontColor, Color effectColor, int scope)
            {
                Bitmap bitmap = null;//实例化Bitmap类
                using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))//实例化Graphics类
                {
                    SizeF size = g.MeasureString(text, font);//对字符串进行测量
                    using (Bitmap bmp = new Bitmap((int)size.Width, (int)size.Height))//通过文字的大小实例化Bitmap类
                    using (Graphics bmpG = Graphics.FromImage(bmp))//实例化Bitmap类
                    using (SolidBrush sbBack = new SolidBrush(Color.FromArgb(16, effectColor.R, effectColor.G, effectColor.B)))//根据RGB的值定义画刷
                    using (SolidBrush sbFore = new SolidBrush(fontColor))//定义画刷
                    {
                        bmpG.SmoothingMode = SmoothingMode.HighQuality;//设置为高质量
                        bmpG.InterpolationMode = InterpolationMode.HighQualityBilinear;//设置为高质量的收缩
                        bmpG.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;//消除锯齿
                        bmpG.DrawString(text, font, sbBack, 0, 0);//给制文字
                        bitmap = new Bitmap(bmp.Width + scope, bmp.Height + scope);//根据辉光文字的大小实例化Bitmap类
                        using (Graphics bitmapG = Graphics.FromImage(bitmap))//实例化Graphics类
                        {
                            bitmapG.SmoothingMode = SmoothingMode.HighQuality;//设置为高质量
                            bitmapG.InterpolationMode = InterpolationMode.HighQualityBilinear;//设置为高质量的收缩
                            bitmapG.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;//消除锯齿
                            //遍历辉光文字的各象素点
                            for (int x = 0; x <= scope; x++)
                            {
                                for (int y = 0; y <= scope; y++)
                                {
                                    bitmapG.DrawImageUnscaled(bmp, x, y);//绘制辉光文字的点
                                }
                            }
                            bitmapG.DrawString(text, font, sbFore, scope / 2, scope / 2);//绘制文字
                        }
                    }
                }
    
                return bitmap;
            }
  • 相关阅读:
    详解CSS中:nth-child的用法
    网站哀悼变灰代码集合 兼容所有浏览器的CSS变暗代码
    简单CSS3实现炫酷读者墙
    CSS常用浮出层的写法
    五种方法让CSS实现垂直居中
    网页前端开发:微博CSS3适用细节初探
    CSS代码实例:用CSS代码写出的各种形状图形
    10个CSS简写及优化技巧
    25个站长必备的SEO优化工具
    40个让你的网站屌到爆的jQuery插件
  • 原文地址:https://www.cnblogs.com/qq1223558/p/3410025.html
Copyright © 2011-2022 走看看