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;
            }
  • 相关阅读:
    用数据泵技术实现逻辑备份Oracle 11g R2 数据泵技术详解(expdp impdp)
    用mysql实现类似于oracle dblink的功能
    统计1的个数
    转置字符串,其中单词内的字符需要正常
    经典排序之归并排序
    公共子序列与公共子串问题
    placement new (转)
    数组排序组合最小数字
    实现两个数相加不用四则运算
    操作系统中作业、线程、进程、内存管理、垃圾回收以及缓存等概念
  • 原文地址:https://www.cnblogs.com/qq1223558/p/3410025.html
Copyright © 2011-2022 走看看