输入一个图片,获得转换成为指定大小的图片

收藏:
private   System.Drawing.Bitmap   ResizeBMP(System.Drawing.Bitmap   source_bmp,int   new_width,int   new_height)  
  {  
  float   x_rate=(float)source_bmp.Width/(float)new_width;   
  float   y_rate=(float)source_bmp.Height/(float)new_height;  
  System.Drawing.Bitmap   cache_bmps=new   Bitmap(new_width,new_height,PixelFormat.Format24bppRgb);  
  for(int   cy=0;cy<new_height;cy++)  
  {  
  for(int   cx=0;cx<new_width;cx++)  
  {  
  cache_bmps.SetPixel(cx,cy,source_bmp.GetPixel((int)((cx+1)*x_rate-1),(int)((cy+1)*y_rate-1)));  
  }  
  }  
  return   cache_bmps;  
  }


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hanghwp/archive/2009/09/04/4517408.aspx

原文地址:https://www.cnblogs.com/lifuyun/p/lifuyun00000.html