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
; }
}
}
}
查看全文
相关阅读:
探索ASP.NET MVC5系列之~~~3.视图篇(下)---包含常用表单和暴力解猜防御
探索ASP.NET MVC5系列之~~~2.视图篇(上)---包含XSS防御和异步分部视图的处理
SVN:Previous operation has not finished; run 'cleanup' if it was interrupted
探索ASP.NET MVC5系列之~~~1.基础篇---必须知道的小技能
MVC:The name 'Scripts' does not exist in the current context
Dapper.Contrib:GetAsync<T> only supports an entity with a [Key] or an [ExplicitKey] property
Dapper扩展之~~~Dapper.Contrib
AutoFac在项目中的应用
群福利:百度云管家-本地SVIP
【声明】前方不设坑位,不收费!~ 我为NET狂官方学习计划
原文地址:https://www.cnblogs.com/goodspeed/p/25564.html
最新文章
Android App组件之ListFragment -- 说明和示例
Android App组件之Fragment说明和示例
Android App组件之Activity
Android控件之ImageSwticher
Android 之窗口小部件详解--App Widget
Java引用总结--StrongReference、SoftReference、WeakReference、PhantomReference
Android 布局之GridLayout
Android 布局之FrameLayout
Android 布局之TableLayout
Android 布局之RelativeLayout
热门文章
Android 布局之LinearLayout
编辑器之神VIM 总结(一) 基础部分
Android按键添加和处理的方案
Android 开机画面和wallpaper总结
Android manifest之manifest标签详细介绍
中文分词之结巴分词~~~附使用场景+demo(net)
我为NET狂~群福利:逆天书库
bootstrap-datetimepicker 进一步跟进~~~开始时间和结束时间的样式显示
Dapper:The member of type SeoTKD cannot be used as a parameter Value
探索ASP.NET MVC5系列之~~~4.模型篇---包含模型常用特性和过度提交防御
Copyright © 2011-2022 走看看