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;
            }
  • 相关阅读:
    移动端开发rem布局之less+媒体查询布局的原理步骤和心得
    前端实现文件下载方式总汇
    如何能提高CSS编写技巧?提高Web前端开发效率
    常用的CSS命名规则
    CSS背景background
    CSS盒子模型
    简单的树形菜单如何写?
    彻底掌握css动画【transition】
    首页白屏优化实践
    我来聊聊面向模板的前端开发
  • 原文地址:https://www.cnblogs.com/qq1223558/p/3410025.html
Copyright © 2011-2022 走看看