All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
C#中PerformanceCounter组件应用实例
ASP.NET技巧:错误处理封装_[Asp.Net教程]_0
SQL数据操作基础(中级)6_mssql学习_编程技术
《Effective,C#》:值类型和引用类型_[Asp.Net教程]
asp.net2.0中GridView控件应用实例
Asp实现获取xml中的内容_[XML教程]
SQL,Server,CLR全功略之二---CLR存储过程_mssql学习_编程技术
SQL中CASE使用_mssql学习_编程技术
优化SQL语句性能调整原则_[SQL Server教程]
delphi自绘栅格组件(TDrawGrid)使用方法
Reading number is top 10 pictures
The real super beauty2
007 James. bond's new lover
Seductive beauty of crime1
Absolutely shocked. National geographic 50 animal photographys3
西班牙山村小景5
全球十大灵异酒店
生活中总有些低调的人,不经意间散发出土豪的气质
Sora aoi on twitter3
男人帮杂志里的惹火性感美女2
From China fortress sora aoi2
Download software ranking
Tram sex maniac 2 (H) rar bag12
变速齿轮3.26
C#与.NET技术平台实战演练
Jinling thirteen stock
电车之狼R
Tram sex maniac 2 (H) rar bag17
The king of fighters 97(Mobile phone games-apk)
株洲本地在线棋牌游戏
尖东毒玫瑰A
VC++6.0培训教程
delv published in(发表于) 2014/1/24 9:03:48 Edit(编辑)
ASP.NET2.0图片格式转换_[Asp.Net教程]

ASP.NET2.0图片格式转换_[Asp.Net教程]

ASP.NET2.0图片格式转换_[Asp.Net教程]

































说明:本文实现了
图片格式随意转换(下拉框选择);
点击FileUpload立即显示图片(Js实现)的技巧;




第一步:打开页面




第二步:选择一副Jpg格式的图片




第三步:转换为GIF格式,明显看出图片画质降低。







后台代码:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string filepath = FileUpload1.PostedFile.FileName;
string filename = filepath.Substring(filepath.LastIndexOf("\\") + 1);
string serverpath = Server.MapPath("images/") + System.DateTime.Now.ToString("yyy-MM-dd-hh-mm-ss") + Session.SessionID + filename;




if (DropDownList1.SelectedValue == "GIF")
{
ConvertImage(FileUpload1.PostedFile.FileName, System.Drawing.Imaging.ImageFormat.Gif, serverpath+".gif");
}
else if(DropDownList1.SelectedValue == "Jpeg")
{
ConvertImage(FileUpload1.PostedFile.FileName, System.Drawing.Imaging.ImageFormat.Jpeg, serverpath + ".jpg");
}
else if(DropDownList1.SelectedValue == "Bmp")
{
ConvertImage(FileUpload1.PostedFile.FileName, System.Drawing.Imaging.ImageFormat.Bmp, serverpath + ".bmp");
}
else
{
//清清月儿留给大家http://blog.csdn.net/21aspnet
}
}




public void ConvertImage(string Filename, System.Drawing.Imaging.ImageFormat DesiredFormat, string NewFilename)
{
try
{
System.Drawing.Image imgFile = System.Drawing.Image.FromFile(Filename);
imgFile.Save(NewFilename, DesiredFormat);
Image1.ImageUrl = NewFilename;
Label1.Text = "转换成功,生成"+NewFilename+",如下所示。";
TextBox1.Text = "1";//开始为0,转换后为1
}
catch (Exception ex)
{
Response.Write(ex);
}
}




}







前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>









图片格式转换







&nbsp;









onmouseover="show_img()" Width="349px"/>&nbsp;






格式
GIF
Jpeg
Bmp
Png
Ico







onClick="Button1_Click" Text="转换" />





0












&nbsp;




























来源:http://blog.csdn.net/21aspnet/
















































添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.