![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
asp.net 在一个图片上画图,然后显示 100
展开全部
这是一个画 9*9 乘法表的 和你要的类似你看看吧
System.Drawing.Bitmap image = new System.Drawing.Bitmap(600,250);
Graphics g = Graphics.FromImage(image);
try
{
int x = 5;
int y = 50;
//清空图片背景色
g.Clear(Color.White);
Font font = new System.Drawing.Font("Arial", 12, (System.Drawing.FontStyle.Bold));
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.DarkRed, 1.2f, true);
g.DrawString("九九乘法歌诀", font, brush,200, 5);
g.DrawLine(new Pen(Color.Silver), 0, 30, 600, 30);
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= i; j++)
{
string str = j + "×" + i + "=" + j * i + " ";
g.DrawString(str, font, brush,x, y);
x = x + str.Length + 60;
}
y = y + 20;
x = 5;
}
//画图片的边框线
g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
finally
{
g.Dispose();
image.Dispose();
}
System.Drawing.Bitmap image = new System.Drawing.Bitmap(600,250);
Graphics g = Graphics.FromImage(image);
try
{
int x = 5;
int y = 50;
//清空图片背景色
g.Clear(Color.White);
Font font = new System.Drawing.Font("Arial", 12, (System.Drawing.FontStyle.Bold));
System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.DarkRed, 1.2f, true);
g.DrawString("九九乘法歌诀", font, brush,200, 5);
g.DrawLine(new Pen(Color.Silver), 0, 30, 600, 30);
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= i; j++)
{
string str = j + "×" + i + "=" + j * i + " ";
g.DrawString(str, font, brush,x, y);
x = x + str.Length + 60;
}
y = y + 20;
x = 5;
}
//画图片的边框线
g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
finally
{
g.Dispose();
image.Dispose();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询