菜鸟求教!asp.net图像处理问题
请看下列程序:将多个tif图像合并生成一个pdf文档,运用了itextsharp组件
——————tif2bdf————————
<%@ Page language="c#" Codebehind="tiff2pdf.aspx.cs" AutoEventWireup="false" Inherits="zhl.tiff2pdf" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>tiff2pdf</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 56px; POSITION: absolute; TOP: 56px" runat="server"></asp:Label>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 64px; POSITION: absolute; TOP: 80px" runat="server"
Text="tif2pdf"></asp:Button>
<asp:Label id="Label2" style="Z-INDEX: 103; LEFT: 344px; POSITION: absolute; TOP: 96px" runat="server"></asp:Label>
<asp:Label id="Label3" style="Z-INDEX: 104; LEFT: 344px; POSITION: absolute; TOP: 144px" runat="server"></asp:Label></FONT>
</form>
</body>
——————————————————————————
——————————tif2bdf.aspx.cs——————————
using System;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
//using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Drawing.Imaging;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace zhl
{
/// <summary>
/// tiff2pdf 的摘要说明。
/// </summary>
public class tiff2pdf : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
Response.Write("tiff to pdf");
}
#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)
{
string [] path={@"D:\1.tif",@"D:\2.tif",@"D:\3.tif"};//请注意,路径是本地硬盘路径!!
//int end=0;
// creation of the document with a certain size and certain margins
Document document = new Document(PageSize.A4, 0, 0, 0, 0);
//Document.compress = false;
try
{
// creation of the different writers
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@"D:\pdf\Chap0611.pdf", FileMode.Create));
System.Drawing.Bitmap bm;
PdfContentByte cb;
int total;
document.Open();
for(int i=0;i<3;i++)
{
bm = new System.Drawing.Bitmap(path[i]);//其中path[i]是本地硬盘的路径
total = bm.GetFrameCount(FrameDimension.Page);
cb = writer.DirectContent;
Label2.Text=total.ToString();
for (int k = 0; k < total; ++k)
{
bm.SelectActiveFrame(FrameDimension.Page, k);
Image img = Image.GetInstance(bm, null, true);
//img.ScalePercent(72f / 200f * 100);
img.ScalePercent(58f / 200f * 100);
img.SetAbsolutePosition(0, 0);
Label3.Text+="Image: " + k+"|";
cb.AddImage(img);
document.NewPage();
}
}
document.Close();
}
catch (Exception de)
{
Label1.Text += de.Message;
Label1.Text += de.StackTrace;
}
}
}
}
——————————————————————————————
上边的东西提供给大家,不过不看也罢,问题就是:
bm = new System.Drawing.Bitmap(@"D:\1.tif");
如果,我需要的图片来自于网络,比如,我需要的tif文件来自于http:\\www.xxxxx.com\1.tif
那我该怎么用程序进行处理阿?
bm = new System.Drawing.Bitmap("http:\\www.xxxxx.com\1.tif");肯定是不行的,那该怎么办呢?
难道要先下载下来再进行处理吗?那样这样的程序做网络版直接就没用了,郁闷阿!
该怎么样才能直接通过网络的路径来进行初始化bm呢,或者有什么更好的办法,希望大虾们指点一下阿!请给出示例代码。
大家帮忙顶一下好吗!