输入一个图片,获得转换成为指定大小的图片
收藏:
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
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步