-1
例外我想保存我調整大小的圖像,但我得到一個GDI +錯誤。代碼:GDI + Bitmap.Save
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(path));
float aspectRatio = (float)image.Size.Width/(float)image.Size.Height;
int newHeight = 200;
int newWidth = Convert.ToInt32(aspectRatio * newHeight);
System.Drawing.Bitmap thumbBitmap = new System.Drawing.Bitmap(newWidth, newHeight);
System.Drawing.Graphics thumbGraph = System.Drawing.Graphics.FromImage(thumbBitmap);
thumbGraph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
thumbGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
thumbGraph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
thumbGraph.DrawImage(image, imageRectangle);
thumbBitmap.Save("~/images/galeria/thumb/" + FileUpload1.FileName);
thumbGraph.Dispose();
thumbBitmap.Dispose();
image.Dispose();
錯誤是由這一行造成的:
thumbBitmap.Save("~/images/galeria/thumb/" + FileUpload1.FileName);
任何想法如何解決這個問題?
EDIT1:
類型「System.Runtime.InteropServices.ExternalException」的一個例外發生在System.Drawing.dll程序但在用戶代碼
附加信息沒有處理:在GDI發生一般性錯誤+ 。
請給我們完整的錯誤描述。 –
調試器。斷點。使用它們,也許,你能給我們完整的錯誤? – 2015-11-02 19:37:19
確定它是一個有效的路徑?有寫權限? – TaW