简体   繁体   English

应用Aforge.NET过滤器后保存图像

[英]Saving an Image after applying an Aforge.NET filter

I have the following snippet which loads an image from memory, resizes it, and attempts to save the resized image. 我有以下片段,该片段从内存中加载图像,调整其大小,然后尝试保存调整后的图像。 I get the "A generic error occurred in GDI+" error on the resizedImage.Save(), but I can't see where an image/bitmap is being held on to. 我在resizeImage.Save()上收到“ GDI +中发生一般错误”错误,但是我看不到图像/位图保留在何处。 Any help would be appreciated. 任何帮助,将不胜感激。

    using (var m = new MemoryStream(File.ReadAllBytes(fileName)))
                {
                    using (var n = new Bitmap(m))
                    {
                        using (var newImage = n.Clone(new Rectangle(0, 0, n.Width, n.Height), PixelFormat.Format24bppRgb))
                        {
                            var filter = new ResizeBicubic(200, 200);
                            var resizedImage = filter.Apply(newImage);

                            resizedImage.Save(searchImage);
                            resizedImage.Dispose();
                        }
                    }
                }

You cannot save the image at the same origin file. 您不能将图像保存在相同的原始文件中。 Try to change the output file. 尝试更改输出文件。 AForge keeps the origin file Open. AForge使原始文件保持打开状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM