时间:2016-02-15 22:51 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【理解HttpHandler,并为所有*.jpg图片生成一段文字于图片上】,下面是详细的讲解!
理解HttpHandler,并为所有*.jpg图片生成一段文字于图片上
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.SessionState;
using System.Drawing;
/// <summary>
/// Class1 的摘要说明
/// </summary>
public class Class1:IHttpHandler
{
public Class1()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public bool IsReusable
{
get { return true; }
}
private static Image OldImage=null;
private static Image GetOldImage(HttpContext context)
{
if (OldImage==null)
{
OldImage=Image.FromFile(context.Server.MapPath("~/Images/Old.jpg"));
}
return OldImage.Clone() as Image;
}
public void ProcessRequest(HttpContext context)
{
Image newimage=GetOldImage(context);
Graphics gh=Graphics.FromImage(newimage);
Font font=new Font("Monaco", 24.0f, FontStyle.Regular);
string writetext=HttpUtility.UrlEncode(context.Request.QueryString["writetext"]);
gh.DrawString(HttpUtility.UrlDecode(writetext), font, new SolidBrush(Color.LightBlue), 20.0f, newimage.Height - font.Height - 30);
newimage.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
gh.Dispose();
newimage.Dispose();
}
}
关于理解HttpHandler,并为所有*.jpg图片生成一段文字于图片上的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【DataSet】DataSet、DataTable、DataRow区别详解
- 【asp】asp.net 动态添加多个用户控件-net-动态添
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【asp】asp.net ubb使用代码-net-ubb使用
- 【默认图片】图片不存在使用默认图片代替的实例
- 【asp】asp.net 页面转向 Response.Redirect Ser
- 【jQuery】jQuery实现倒计时跳转的例子-倒计时跳
- 【页面打印】关于ASP.NET页面打印技术的常用方法
- 【MVC5】MVC 5 第一章 创建MVC 5 web应用程序-net
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
