3

Accord.NET PointsMarker.csは、PixelFormatFormat32bppArgbをサポートしているようです。なぜこれがUnsupportedImageFormatExceptionをキャッチするのですか?

private void Harris()
{
    try
    {
        img1 = new Bitmap(pictureBox1A.Image);
        img2 = new Bitmap(pictureBox1B.Image);
        var harris = new HarrisCornersDetector(0.04f, 1000f);
        harrisPoints1 = harris.ProcessImage(img1).ToArray();
        harrisPoints2 = harris.ProcessImage(img2).ToArray();
        // Show the marked points in the original images
        var img1mark = new PointsMarker(harrisPoints1).Apply(img1);
        var img2mark = new PointsMarker(harrisPoints2).Apply(img2);
        // Concatenate the two images together in a single image
        var concatenate = new Concatenate(img1mark);
        pictureBox.Image = concatenate.Apply(img2mark);
    }
    catch (UnsupportedImageFormatException)
    {
        const string S = "UnsupportedImageFormatException PixelFormat ";
        Console.WriteLine(S + img1.PixelFormat);
        Console.WriteLine(S + img2.PixelFormat);
    }
}

Console.WriteLineは

UnsupportedImageFormatException PixelFormat Format32bppArgb UnsupportedImageFormatException PixelFormat Format32bppArgb

4

2 に答える 2

4

Format32bppArgb は Accord.NET PointsMarker.csソースでサポートされているようですが、これを追加することで修復できました。

// Convert to Format24bppRgb
private static Bitmap Get24bppRgb(Image image)
{
    var bitmap = new Bitmap(image);
    var bitmap24 = new Bitmap(bitmap.Width, bitmap.Height, PixelFormat.Format24bppRgb);
    using (var gr = Graphics.FromImage(bitmap24))
    {
        gr.DrawImage(bitmap, new Rectangle(0, 0, bitmap24.Width, bitmap24.Height));
    }
    return bitmap24;
}
于 2011-12-28T20:02:49.047 に答える
-2

この問題を回避するもう 1 つの方法は、画像をSystem.Drawing.Image(たとえばxxx.jpg etc) として保存することです。次に、画像を画像として読み戻し、ビットマップに変換します。
それは私のために働いた。

于 2012-10-30T16:08:04.157 に答える