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 ); // Get Image
Method 2 # RegionMethod 2
//Byte [] mydatabuffer = WC. downloaddata (URL );
//Response. binarywrite (mydatabuffer );
# Endregion
Watermark # Region Watermark
Image newimage = Image. fromfile ( " C: \ watermark1.gif " );
// Watermark
Using (Graphics g = Graphics. fromimage (originalimage ))
{
Point ulcorner = New Point (originalimage. Width - Newimage. Width - 5 , Originalimage. Height - Newimage. Height - 5 ); // Watermark position
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;}
}
}
}