惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
IT之家
IT之家
T
The Blog of Author Tim Ferriss
V
V2EX
博客园 - 聂微东
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
U
Unit 42
Vercel News
Vercel News
L
LangChain Blog
博客园 - 司徒正美
H
Help Net Security
Recent Announcements
Recent Announcements
Recorded Future
Recorded Future
V
Visual Studio Blog
Jina AI
Jina AI
Microsoft Azure Blog
Microsoft Azure Blog
GbyAI
GbyAI
Y
Y Combinator Blog
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
J
Java Code Geeks
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
B
Blog RSS Feed
F
Fortinet All Blogs
B
Blog
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
罗磊的独立博客
博客园_首页
MyScale Blog
MyScale Blog
aimingoo的专栏
aimingoo的专栏
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
量子位
I
InfoQ
小众软件
小众软件
P
Proofpoint News Feed

博客园 - leon qian

正则表达式全部符号解释 android显示大图片的一些技巧 SAPI 5.1 语音合成的事件 SAPI 5.1 语音合成的列举语音引擎 Unicode符号代码表 c#中的问号 C#的四则运算函数 - leon qian - 博客园 读取Excel文件时出现null的解决方法 - leon qian - 博客园 让CSS区别不同浏览器 在Repeater中使用按钮或其他控件的解决方法 - leon qian - 博客园 在IIS中使用Gzip压缩后传送数据 一堆常用JS代码 stream转string,string转stream 一个XML转换的例子 JS代码整理 由于启动用户实例的进程时出错的解决方法 C#中的正则表达式 转 SqlHelper详解(转载) [转].net用url重写URLReWriter实现任意二级域名
asp.net 真正意义上的裁减图片
leon qian · 2007-07-22 · via 博客园 - leon qian

private void Page_Load(object sender, System.EventArgs e)
  {
   ImgReduceCutOut(64,64,"1.jpg","2.jpg");
  }

  /// <summary>
  /// 缩小裁剪图片
  /// </summary>
  /// <param name="int_Width">要缩小裁剪图片宽度</param>
  /// <param name="int_Height">要缩小裁剪图片长度</param>
  /// <param name="input_ImgUrl">要处理图片路径</param>
  /// <param name="out_ImgUrl">处理完毕图片路径</param>
  public void ImgReduceCutOut(int int_Width,int int_Height,string input_ImgUrl,string out_ImgUrl)
  {

   int CutOut_Width=0; // 裁剪的宽度
   int CutOut_Height=0; // 裁剪的高度
   int level = 100; //缩略图的质量 1-100的范围

   CutOut_Width=int_Width;
   CutOut_Height=int_Height;

   System.Drawing.Image oldimage = System.Drawing.Image.FromFile(Server.MapPath(input_ImgUrl));
   Bitmap bm=new Bitmap(oldimage);

   ImageCodecInfo[] ImageCode=ImageCodecInfo.GetImageEncoders();
   ImageCodecInfo ii=null;
   foreach(ImageCodecInfo i in ImageCode)
   {
    if(i.MimeType=="image/jpeg") ii=i;
   }
   EncoderParameters ep=new EncoderParameters();
   ep.Param[0]=new EncoderParameter(Encoder.Quality,(long)level);


   Rectangle cloneRect = new Rectangle(20,20, CutOut_Width, CutOut_Height);
   PixelFormat format = bm.PixelFormat;
   Bitmap cloneBitmap = bm.Clone(cloneRect, format);

   cloneBitmap.Save(Server.MapPath(out_ImgUrl),ii,ep);
  }