位图保存gdi +中发生的一般错误

时间:2012-07-03 17:45:03

标签: c# asp.net gdi+

我在保存此Bitmap时遇到问题。我尝试了ImageFormat.Jpg格式但结果相同。我确信这条道路是真的。

        string filePathTemp = Server.MapPath("..") + @"\ProductImages\Temp\";

        ImageProcessor imageProcessor = new ImageProcessor();

        fuProductImage.SaveAs(filePathTemp + fuProductImage.FileName);

        Bitmap orgImage = new Bitmap(filePathTemp + fuProductImage.FileName);

        Bitmap resizedLargeImage = imageProcessor.Resize(orgImage, 350, 350);

        resizedLargeImage.Save(filePathLarge, ImageFormat.Bmp);

我的错误很有名,除非在gdi +中发生了一般性错误。你有什么建议吗?

由于

1 个答案:

答案 0 :(得分:2)

                ImageConverter img_converter = new ImageConverter();
                System.Drawing.Image img = imageProcessor.Resize(orgImage, width, height);

                byte[] bytes = (byte[])img_converter.ConvertTo(img, typeof(byte[]));

                File.WriteAllBytes(filePath + fileName, bytes);