using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
namespace Image.Util
{
class ShapeImage
{
/// <summary>
/// 画一个带数字的饼图
/// </summary>
/// <param name="digit"></param>
/// <param name="color"></param>
/// <returns></returns>
public static Bitmap GetPieWithDigit(int digit,Color color)
{
int size = ;
if ((digit < ) || (digit > )) throw new Exception("数值超范围");
Bitmap bmp = new Bitmap(size, size);
Graphics g = Graphics.FromImage(bmp);
g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.CompositingQuality = CompositingQuality.HighQuality;
g.FillPie(new SolidBrush(color), new Rectangle(, , size-, size-), , );
Point centerPoint = new Point(size / , size / );
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
if (digit.ToString().Length == )
{
g.DrawString(digit.ToString(), new Font("微软雅黑", ), new SolidBrush(Color.White), new Rectangle(, , size, size), stringFormat);
}
else
g.DrawString(digit.ToString(), new Font("微软雅黑", ), new SolidBrush(Color.White), new Rectangle(, , size, size), stringFormat);
return bmp;
}
}
}