通过WebRequest获取远程网页图片
来源:互联网 发布:cf审判无影腿编程 编辑:程序博客网 时间:2024/04/29 19:57
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Net;
namespace WebRequest
{
/// <summary>
/// 捷 2005-5-7
/// 通过WebRequest获取远程网页图片
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
try
{
string imgpath = this.TextBox1.Text;
string file_name = "1.jpg";
HttpWebRequest wrequest;
HttpWebResponse wresponse;
Stream s;
wrequest = (HttpWebRequest)HttpWebRequest.Create(imgpath);
wresponse = (HttpWebResponse)wrequest.GetResponse();
s = wresponse.GetResponseStream();
System.Drawing.Image simg = System.Drawing.Image.FromStream(s);
Bitmap newimg = new Bitmap(simg);
int x = newimg.Width-100;
int y = newimg.Height-25;
if(y >= 200 && x >= 200)
{
Graphics g = Graphics.FromImage(newimg);
g.FillRectangle(new LinearGradientBrush(new Point(0,0), new Point(100,25),Color.Black, Color.Black),x,y,100,25); //Color.FromArgb(0,0,0,0)
g.DrawString(" My World", new Font("黑体",13),new SolidBrush(Color.White),new PointF(x+4,y+3));//,FontStyle.Bold
}
newimg.Save(Server.MapPath("images/") + file_name,System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch
{
Response.Redirect("~/error.htm?msg=" + Server.UrlEncode("未找到文件!"));
}
}
}
}
- 通过WebRequest获取远程网页图片
- 通过WebRequest 类来获取远端页面。
- php通过cookies获取远程网页的指定代码
- C# winfrom WebRequest获取html网页信息 引用using
- c#利用WebClient和WebRequest获取网页源代码的比较
- c#利用WebClient和WebRequest获取网页源代码的比较
- c#利用WebClient和WebRequest获取网页源代码的比较
- c#利用WebClient和WebRequest获取网页源代码
- c#利用WebClient和WebRequest获取网页源代码的比较
- C#利用webrequest 通过图片src保存到本地
- PHP通过正则表达式获取网页中的所有图片
- PHP通过正则表达式获取网页中的所有图片
- 获取远程网页内容
- c#通过webrequest请求远程http服务时出现的问题
- php远程获取图片
- java获取远程图片
- c#获取远程图片
- php 获取远程图片
- 移动光标到input最后
- Debug SQL Easily by Charles Carroll
- ASP中怎么获得被更新或新增的记录数?
- J2ME中使用随机数
- 使用梅花雨
- 通过WebRequest获取远程网页图片
- repeater里添加序号的两种方法(前台,后台)
- 变态级JAVA程序员面试32问(转)
- JavaScript写的Cookie类
- Cookie的概述及应用。
- 打造安全的服务器,服务器防黑技术
- SQL Server 中系统表的作用
- 发布软件——电子节拍器
- 这是4点零8分的北京