2
我需要一些幫助裁剪和使用CSharp.net調整圖像大小。我的目標是拍攝一張圖像並將其縮小至50像素×50像素。我在這裏找到的下面的代碼將做到這一點,但它也是縮放圖像。理想情況下,我希望將圖像縮小至最接近50像素×50像素,然後刪除圖像中50像素以外50像素的部分。裁剪和調整圖像到具體尺寸
public Image ResizeImage(Image img, int width, int height)
{
Bitmap b = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage((Image)b))
{
g.DrawImage(img, 0, 0, width, height);
}
return (Image)b;
}
它確實,在這個帖子的鏈接解決我的問題: http://stackoverflow.com/questions/1626355/best-resize-and -or-作物邏輯/ 1649349#1649349 – Crunchy 2011-01-15 21:32:20