图片水印
来源:互联网 发布:计算瓷砖用量软件 编辑:程序博客网 时间:2024/04/28 03:34
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.IO;
using System.Drawing;
using System.Text;
namespace xhyBookShop
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class ImgHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
string path = context.Server.MapPath("~/BookPic/");
string fileSrc = path + context.Request["src"];
string defSrc = path + "default.jpg";
string waterSrc = path + "sign.jpg";
Image pic = null;
//创建站点图片
context.Response.ContentType = "image/jpg";
Image waterPic = Image.FromFile(waterSrc);
//创建水印绘图对象
Graphics wg = Graphics.FromImage(waterPic);
//绘制
wg.DrawString(
"title",
new Font("粗体", 15, FontStyle.Bold),
Brushes.Black,
new Point(20, 12));
wg.Dispose();
if (File.Exists(fileSrc))
{
//设置输出类型
context.Response.ContentType = "image/jpg";
//创建图片
pic = Image.FromFile(fileSrc);
//绘制
Graphics g = Graphics.FromImage(pic);
g.DrawImage(waterPic, 0, 0);
g.Dispose();
}
else
{
//设置输出类型
context.Response.ContentType = "image/jpg";
//创建图片
pic = Image.FromFile(defSrc);
//创建绘图对象
Graphics g = Graphics.FromImage(pic);
//绘制
g.DrawImage(waterPic, 0, 0);
//g.DrawString(
// "title",
// new Font("粗体", 15, FontStyle.Bold),
// Brushes.Black,
// new Point(0, 0));
g.DrawString(
"暂无图片",
new Font("粗体", 30, FontStyle.Bold),
Brushes.Gray,
new Point(0, 60));
}
context.Response.ContentType = "image/jpeg";
pic.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
pic.Dispose();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
- 图片水印
- 图片水印
- 图片水印
- 水印图片
- 水印图片
- 图片水印
- 图片水印
- 图片水印
- 图片水印
- 图片水印
- 图片水印
- 图片水印
- 图片水印
- 图片水印
- 水印图片
- Java添加水印+图片水印+文字水印
- php 图片水印 文字水印
- 水印图片、图片旋转
- [精品教程,新老鸟必读]:极限装机、优化全攻略(新手优化教程)
- 通过自建的Twitter API Proxy让Twitterfox完美地登陆Twitter
- .NET4.0并行计算技术基础(10)
- 某年某日晚,顿悟!
- 有关fanout
- 图片水印
- LINUX服务器配置视频演示汇总大餐
- SSL + WS-Security = Web Service安全保障
- 文件读写(xml)
- 互联网服务技术架构方面的理念、原则,方法
- 怎样下载优酷视频
- 关于 SQL2005 远程备份
- 文件、图片上传
- 太极音乐下载