成人午夜激情影院,小视频免费在线观看,国产精品夜夜嗨,欧美日韩精品一区二区在线播放

當前位置:首頁>>開發(fā)編程>>VS.NET>>新聞內容
用ASP.NET上傳圖片并生成帶版權信息的縮略圖
作者:活靶子 發(fā)布時間:2003-10-8 16:50:29 文章來源:AspxBoy.Com

<%@ Page Language="C#" ResponseEncoding="gb2312" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<script runat="server">

void Page_Load(Object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
ImgPreview.Visible=false;
}
}
void GetThumbnailImage(int width,int height,string strInfo,int left,int right)
{
string file="Uploads/"+uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\\')+1);
string newfile="Uploads/"+uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\\')+1)+".jpg";
string strAdd=strInfo;
System.Drawing.Image oldimage = System.Drawing.Image.FromFile(Server.MapPath(file));
System.Drawing.Image thumbnailImage =
oldimage.GetThumbnailImage(width, height,new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
Response.Clear();
Bitmap output=new Bitmap(thumbnailImage);
Graphics g=Graphics.FromImage(output);
g.DrawString(strAdd,new Font("Courier New", 14),new SolidBrush(Color.Red),left,right);
output.Save(Server.MapPath(newfile),System.Drawing.Imaging.ImageFormat.Jpeg);
Response.ContentType = "image/gif";
ImgPreview.Visible=true;
ImgPreview.ImageUrl=newfile;
}
bool ThumbnailCallback()
{
return true;
}

void Button_Click(object sender, EventArgs e)
{
int width,height,left,right;
string strAddInfo=txtAddInfo.Text;
width=Int32.Parse(txtWidth.Text);
height=Int32.Parse(txtHeight.Text);
left=Int32.Parse(txtLeft.Text);
right=Int32.Parse(txtRight.Text);
if(!(uploadFile.PostedFile.ContentLength>0))
{
lblErrInfo.Text="沒有選擇文件";
}
else
{

string path = Server.MapPath("./Uploads/"+uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\\')+1));
if(File.Exists(path))
{
lblErrInfo.Text="已經有同名文件";
}
else
{
uploadFile.PostedFile.SaveAs(path);
GetThumbnailImage(width,height,strAddInfo,left,right);
}
}
}
</script>
<html>
<head>
</head>
<body>
<form method="post" enctype="multipart/form-data" runat="server">
<p>
<input id="uploadFile" type="file" runat="server" />
<asp:Label id="lblErrInfo" runat="server" forecolor="Red"></asp:Label>
</p>
<p>
width:<asp:TextBox id="txtWidth" runat="server" Width="40px">100</asp:TextBox>
 height:<asp:TextBox id="txtHeight" runat="server" Width="40px">150</asp:TextBox>
 
</p>
<p>
添加信息:<asp:TextBox id="txtAddInfo" runat="server">AspxBoy.Com</asp:TextBox>
</p>
<p>
信息位置:left:<asp:TextBox id="txtLeft" runat="server" Width="40px">10</asp:TextBox>
 right:<asp:TextBox id="txtRight" runat="server" Width="40px">135</asp:TextBox>
</p>
<p>
 
<input id="button" type="button" value="上傳生成縮略圖" onServerClick="Button_Click" runat="server" />
</p>
<p><asp:Image id="ImgPreview" runat="server"></asp:Image>
</p>
<!-- Insert content here -->
</form>
</body>
</html>


最新更新
·C#中使用Split分隔字符串的技
·VS2008開發(fā)中Windows Mobile
·PC機和移動設備上絕對路徑的
·C#程序加殼的方法(使用Sixx
·當前上下文中不存在名稱Conf
·請插入磁盤:Visual Studio 2
·用VS.NET讀取Flash格式文件信
·在ASP.NET中使用AJAX的簡單方
·VS.NET 2005中常用的一些代碼
·安裝VS.NET 2005 SP1補丁全攻
相關信息
畫心
愚愛
偏愛
火苗
白狐
畫沙
犯錯
歌曲
傳奇
稻香
小酒窩
獅子座
小情歌
全是愛
棉花糖
海豚音
我相信
甩蔥歌
這叫愛
shero
走天涯
琉璃月
Nobody
我愛他
套馬桿
愛是你我
最后一次
少女時代
灰色頭像
斷橋殘雪
美了美了
狼的誘惑
我很快樂
星月神話
心痛2009
愛丫愛丫
半城煙沙
旗開得勝
郎的誘惑
愛情買賣
2010等你來
我叫小沈陽
i miss you
姑娘我愛你
我們都一樣
其實很寂寞
我愛雨夜花
變心的玫瑰
犀利哥之歌
你是我的眼
你是我的OK繃
貝多芬的悲傷
哥只是個傳說
丟了幸福的豬
找個人來愛我
要嫁就嫁灰太狼
如果這就是愛情
我們沒有在一起
寂寞在唱什么歌
斯琴高麗的傷心
別在我離開之前離開
不是因為寂寞才想你
愛上你等于愛上了錯
在心里從此永遠有個你
一個人的寂寞兩個人的錯
主站蜘蛛池模板: 宁强县| 丰都县| 岫岩| 林甸县| 福鼎市| 富川| 广平县| 南漳县| 芮城县| 涟水县| 华坪县| 祁阳县| 资阳市| 南岸区| 静宁县| 额尔古纳市| 穆棱市| 黄石市| 册亨县| 开封县| 正蓝旗| 静乐县| 东宁县| 关岭| 宁晋县| 垫江县| 灵寿县| 松江区| 曲周县| 青神县| 赣榆县| 阳信县| 大城县| 江北区| 津市市| 广元市| 福泉市| 齐河县| 锡林浩特市| 浦东新区| 宜君县|