我试图通过将上传的流保存到位图中,处理该位图并将处理后的位图保存为应保存到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