不太精确的方法:
public bool ThumbnailCallback() { return false; } private void CreateThumb(int toWidth) { System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); Bitmap myBitmap = new Bitmap("D:\\img100.jpg"); double rate = (double)((double)myBitmap.Width / myBitmap.Height ); int toHeight =(int)((double )toWidth / rate); System.Drawing.Image myThumbnail = myBitmap.GetThumbnailImage(toWidth , toHeight, myCallback, IntPtr.Zero); myThumbnail.Save("D:\\okThumb.jpg"); }
注意:由于int 和double的问题 无法精确。。。。。。。。。。。。。。。。。
来源:https://www.cnblogs.com/wgscd/p/11378699.html