我試圖通過將上傳的流保存到位圖中,處理該位圖並將處理後的位圖保存爲應保存到FTP的新流來調整上傳的圖像的大小夾。上傳的流成功保存爲位圖並正確處理;這只是說,新的處理流呈現爲損壞的圖像時出現問題。這裏是代碼段:將位圖保存到流中
s = FileUpload1.FileContent;
Bitmap bitmap = (Bitmap)Bitmap.FromStream(s);
Bitmap newBmp = new Bitmap(250, 250, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
newBmp.SetResolution(72F, 72F);
Graphics newGraphic = Graphics.FromImage(newBmp);
newGraphic.Clear(Color.White);
newGraphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
newGraphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
newGraphic.DrawImage(bitmap, 0, 0, 250, 250);
newBmp.Save(MapPath("temp.jpg"));
Stream memoryStream = new MemoryStream();
newBmp.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);
我會很感激的任何幫助。提前致謝。 – 2014-12-09 12:48:33
「保存在FTP中」是什麼意思?這是一個網絡協議,而不是文件格式。結果是什麼方式腐敗?是否有錯誤發生,或者是結果中可見的問題?等等。 – 2014-12-09 12:52:00
對不起,我的意思是它應該保存在FTP文件夾中。 – 2014-12-09 12:52:55