gpt4 book ai didi

c# - 如何修复 UnsupportedImageFormatException PixelFormat Format32bppArgb?

转载 作者:行者123 更新时间:2023-11-30 17:14:30 31 4
gpt4 key购买 nike

Accord.NET PointsMarker.cs似乎支持 PixelFormat Format32bppArgb。为什么这会捕获 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

最佳答案

尽管 Accord.NET 似乎支持 Format32bppArgb PointsMarker.cs来源 我可以通过添加 this 来修复它:

// 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;
}

关于c# - 如何修复 UnsupportedImageFormatException PixelFormat Format32bppArgb?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8660432/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com