zoukankan
html css js c++ java
ASP.Net之瞒天过海
using
System;
using
System.Web;
using
System.Drawing;
using
System.Drawing.Imaging;
using
System.Net;
using
System.IO;
namespace
Goodspeed.test.httphandle
{
public
class
myjpg : IHttpHandler
{
public
myjpg()
{ }
public
void
ProcessRequest(HttpContext Context)
{
HttpResponse Response
=
Context.Response;
HttpRequest Request
=
Context.Request;
string
Url
=
Request.Url.ToString();
//
Url = "
http://www.allinone.net.cn/office/photo/pic/20040714/
" + Url.Substring(Url.LastIndexOf("/") + 1);
Url
=
"
http://img1.qq.com/news/20040721/490452.jpg
"
;
Response.ContentType
=
"
image/JPEG
"
;
WebClient wc
=
new
WebClient();
Stream resStream
=
wc.OpenRead(Url);
Image originalimage
=
Image.FromStream(resStream);
//
获取图像
方法二
#region
方法二
//
byte[] myDataBuffer = wc.DownloadData(Url);
//
Response.BinaryWrite(myDataBuffer);
#endregion
水印
#region
水印
Image newImage
=
Image.FromFile(
"
c:\watermark1.gif
"
);
//
水印
using
(Graphics g
=
Graphics.FromImage(originalimage))
{
Point ulCorner
=
new
Point(originalimage.Width
-
newImage.Width
-
5
, originalimage.Height
-
newImage.Height
-
5
);
//
水印的位置
g.DrawImage(newImage, ulCorner);
g.Dispose();
}
#endregion
originalimage.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.End();
originalimage.Dispose();
wc.Dispose();
}
public
bool
IsReusable
{
get
{
return
true
; }
}
}
}
查看全文
相关阅读:
[LuoGu] P1004 方格取数
[LuoGu] P1018 乘积最大
[LuoGu] P2758 编辑距离
[JZOJ] 01知多少
[LuoGu] P1731 生日蛋糕
$mathcal{Const,Inline,Register}$用法总结
T2027 蜈蚣
T57274 黑暗城堡
P2312 解方程
AT2412 最大の和
原文地址:https://www.cnblogs.com/goodspeed/p/25564.html
最新文章
WKWebView 官方文档翻译
<iOS 组件与框架> -- UIKit Dynamics
AVFoundation 官方文档翻译
UICollectionView的拖拽重排
单例模式的实现
一行代码快速搞定发帖时间的显示状态
HTML&CSS日常知识点总结
iOS开发中数据持久化
使用Github来管理的代码片段
iOS开发-程序的生命周期
热门文章
iOS常用控件尺寸大集合
UIDatePicker在swift中的使用
UISegmentedControl在Swift中的使用
Switch在swift中的使用
Swift-函数学习
Swift学习字符串、数组、字典
利用触摸精灵实现截图功能(针对微信)
快速幂(取余运算)
[Codeforces] 1051D Bicolorings
[LuoGu] P3957 跳房子
Copyright © 2011-2022 走看看