* 重构DrawString函数
This commit is contained in:
parent
35b00ce5c2
commit
90c26a6b24
@ -17,12 +17,14 @@
|
||||
* 创建日期: 2022-06-11
|
||||
*
|
||||
* 2022-06-11: V3.1.9 增加文件说明
|
||||
* 2022-05-16: V3.3.6 重构DrawString函数
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sunny.UI
|
||||
{
|
||||
@ -102,9 +104,9 @@ namespace Sunny.UI
|
||||
/// <param name="code">验证码表达式</param>
|
||||
private Bitmap CreateImage(string code)
|
||||
{
|
||||
Font font = new Font(Font.Name, CodeFontSize);
|
||||
Font font = new Font(Font.Name, CodeFontSize, FontStyle.Bold);
|
||||
Code = code;
|
||||
SizeF sf = GDI.MeasureString(code, font);
|
||||
Size sf = TextRenderer.MeasureText(code, font);
|
||||
|
||||
Bitmap image = new Bitmap((int)sf.Width + 16, Height - 2);
|
||||
|
||||
@ -134,7 +136,8 @@ namespace Sunny.UI
|
||||
image.SetPixel(x, y, Color.FromArgb(random.Next()));
|
||||
}
|
||||
|
||||
g.DrawString(code, font, rectColor, image.Width / 2 - sf.Width / 2, image.Height / 2 - sf.Height / 2);
|
||||
using Brush br = new SolidBrush(rectColor);
|
||||
g.DrawString(code, font, br, image.Width / 2 - sf.Width / 2, image.Height / 2 - sf.Height / 2);
|
||||
var imageex = TwistImage(image, true, 5, 5);
|
||||
font.Dispose();
|
||||
image.Dispose();
|
||||
|
Loading…
x
Reference in New Issue
Block a user