关于C#Bitmap System.ArgumentException: 参数无效 问题
<%@WebHandlerLanguage="C#"Class="HttpHandler访问"%>usingSystem;usingSystem.Web;usingSys...
<%@ WebHandler Language="C#" Class="HttpHandler访问" %>
using System;
using System.Web;
using System.Drawing;
using System.Drawing.Imaging;
public class HttpHandler访问 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/JPEG";
string path = HttpContext.Current.Server.MapPath("1.jpg");//运行到这里出现异常
using (Bitmap bitmap = new Bitmap(path))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.DrawString("IP:" + context.Request.UserHostAddress, new Font("黑体", 30), Brushes.Red, 0, 0
);
}
bitmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
}
} 展开
using System;
using System.Web;
using System.Drawing;
using System.Drawing.Imaging;
public class HttpHandler访问 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/JPEG";
string path = HttpContext.Current.Server.MapPath("1.jpg");//运行到这里出现异常
using (Bitmap bitmap = new Bitmap(path))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.DrawString("IP:" + context.Request.UserHostAddress, new Font("黑体", 30), Brushes.Red, 0, 0
);
}
bitmap.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询