0

我正在尝试这个示例,但出现“过滤器不支持源像素格式”错误,为了解决这个问题,我尝试了这些答案,但我得到了标题错误,然后我尝试用这些答案解决它。但我不走运,我不断收到这个错误。

谁能给我一个解决方案?

继承人的代码:

        // Open your image
        string path = "sample2.jpg"; //taken from first example links initial image.
        Bitmap image = (Bitmap)Bitmap.FromFile(path);

        // The original bitmap with the wrong pixel format. 
        // You can check the pixel format with originalBmp.PixelFormat
        //Bitmap originalBmp = new (Bitmap)Image.FromFile("YourFileName.gif");

        // Create a blank bitmap with the same dimensions
        Bitmap tempBitmap = new Bitmap(image.Width, image.Height);

        // From this bitmap, the graphics can be obtained, because it has the right PixelFormat
        using (Graphics g = Graphics.FromImage(tempBitmap))
        {
            // Draw the original bitmap onto the graphics of the new bitmap
            g.DrawImage(image, 0, 0);
            // Use g to do whatever you like
            //g.DrawLine(...);
        }

        //Bitmap EditableImg = new Bitmap(image);

        Bitmap a = AForge.Imaging.Image.Clone(tempBitmap, PixelFormat.Format8bppIndexed); //currently getting titled error here.
        AForge.Imaging.Image.SetGrayscalePalette(a);

        // create filter
        DifferenceEdgeDetector filter = new DifferenceEdgeDetector();
        // apply the filter
        filter.ApplyInPlace(image);

错误图片供参考: 在此处输入图像描述

4

0 回答 0