Asp.net C# 图像处理
2014-08-12 17:41
302 查看
在aspx页面添加一个Image控件,其ImageUrl="Image.aspx",
添加一个Image.aspx,专门用来处理图像,在cs代码里的Page_Load事件处理中写上如下代码:
//原始图像
string physicalPath = Server.MapPath("./129519.jpg");
System.Drawing.Image srcBitmap = Bitmap.FromFile(physicalPath);
//想要的目标图像
int outHeight = srcBitmap.Height * 2;
int outWidth = srcBitmap.Width * 2;
//先创建一个空白的Bitmap
Bitmap outBitmap = new Bitmap(outWidth, outHeight, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(outBitmap);
//在outBitmap 上绘图
Rectangle destRectangle=new Rectangle(0, 0, outWidth, outHeight);
int srcX = 0;
int srcY = 0;
g.DrawImage(srcBitmap, destRectangle/*显示图像的大小*/, srcX,srcY/*从此X,Y坐标开始截取*/,srcBitmap.Width/4/*截取宽*/, srcBitmap.Height/4/*截取高*/, GraphicsUnit.Pixel);
//设置输出类型
Response.ContentType = "image/jpeg";
//向Client 输出
outBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.End();
添加一个Image.aspx,专门用来处理图像,在cs代码里的Page_Load事件处理中写上如下代码:
//原始图像
string physicalPath = Server.MapPath("./129519.jpg");
System.Drawing.Image srcBitmap = Bitmap.FromFile(physicalPath);
//想要的目标图像
int outHeight = srcBitmap.Height * 2;
int outWidth = srcBitmap.Width * 2;
//先创建一个空白的Bitmap
Bitmap outBitmap = new Bitmap(outWidth, outHeight, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(outBitmap);
//在outBitmap 上绘图
Rectangle destRectangle=new Rectangle(0, 0, outWidth, outHeight);
int srcX = 0;
int srcY = 0;
g.DrawImage(srcBitmap, destRectangle/*显示图像的大小*/, srcX,srcY/*从此X,Y坐标开始截取*/,srcBitmap.Width/4/*截取宽*/, srcBitmap.Height/4/*截取高*/, GraphicsUnit.Pixel);
//设置输出类型
Response.ContentType = "image/jpeg";
//向Client 输出
outBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.End();
相关文章推荐
- asp.net c#读取sql server 图像字段
- WPF,WinForms,asp.net开发,图形图像处理系统研究
- ASP.NET 2.0,C#----图像特效处理
- ASP.NET中c#的URL编码处理
- ,asp.net图像处理控件,医疗图像处理控件
- Asp.net C# 图像 裁剪
- 在ASP.NET内处理图像
- 如何实现C#.net图像处理
- .Net GridView 系列:ASP.NET C# GridView 通用样式及动态页尺寸、通用页脚处理
- ASP.NET 2.0,C#----图像特效处理
- HOW TO:在 Visual C# .NET 中创建自定义 ASP.NET 配置节处理程序
- asp.net(C#)放缩图像的代码(源自asp.netStartKit中classKit的作者)
- ASP.NET实例:用C#制作超酷的图像效果
- ASP.NET中c#的URL编码处理
- ASP.NET图像处理详解 [转]
- asp.net(C#)处理数据一个通用类,包括存储过程,适用于初学者[转]
- asp.net c#的传参中经常使用到中文参数的处理,下面的函数可以解决中文参数的问题
- C#中Bitmap类实现对图像操作的一些方法(Asp.net(C#)-放大缩小图片尺寸)
- Asp.net(c#)中的日期处理函数