请教大家这段代码哪里有问题啊?
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Text;
public partial class SuperUser_FreewayWheather : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GraphicsImage();
}
private void GraphicsImage()
{
Bitmap image = new Bitmap("11.jpg");
try
{
Brush brush = new SolidBrush(Color.Red);
Pen pen = new Pen(Color.Blue, 1);
Graphics g = Graphics.FromImage(image);
g.DrawLine(pen, 300, 150, 400, 150);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
Response.ContentType = "image/Gif";
Response.BinaryWrite(ms.ToArray());
}
catch (Exception ms)
{
Response.Write(ms.Message);
}
}
}
代码说明:我想用这段代码实现在一张底图(11.JPG)上绘制一段直线,我运行了以后总是在这句出错Bitmap image = new Bitmap("11.jpg");
请教大家哪里不对,谢谢!
------解决方案--------------------
1.
Bitmap B = new Bitmap(width, height);
B.SetPixel(x,y,Color.FromARGB(redvalue, greenvalue, bluevalue));
or
2
using (Graphics G = Graphics.FromImage('11.jpg'))
{
G.DrawLine(...);
G.FillElliipse(...);
// etc.
}