MyBookShop/BookShop/Handler/WaterImage.ashx.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Web;
namespace BookShop.Handler
{
/// <summary>
/// WaterImage 的摘要说明
/// </summary>
public class WaterImage : IHttpHandler
{
public WaterImage(){}
public void ProcessRequest(HttpContext context)
{
string path = context.Request.PhysicalPath;
if (File.Exists(path))
{
Image img = Image.FromFile(path);
if (img == null)
{
string physicalPath = context.Request.MapPath(@"~/img/Images/BookCovers");
string defaultImagePath = Path.Combine(physicalPath, "noPicture.jpg");
img = Image.FromFile(defaultImagePath);
}
else
{
Graphics g = Graphics.FromImage(img);
g.DrawString("YC87出品", new Font("楷体",20),Brushes.Red,img.Width-40,img.Height-30);
}
Image waterImg = Image.FromFile(context.Request.MapPath(@"~/img/Images/BookCovers"));
context.Response.ContentType = "image/jpg";
img.Save(context.Response.OutputStream,ImageFormat.Jpeg);
img.Dispose();
}
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。