的ArgumentException(参数无效)错误实例化的位图对象
问题描述:
我有以下代码时:的ArgumentException(参数无效)错误实例化的位图对象
位图的位图=新位图(映像路径);
Pathtoimage是jpg的完整绝对路径。我得到一个ArgumentException(参数无效)错误。我究竟做错了什么?
CODE:
Bitmap bitmap = new Bitmap(imageFilename);
var sobelEdgeDetector = new SobelEdgeDetector();
sobelEdgeDetector.Apply(bitmap);
与调用:
var sobelEdgeDetector = new Sobel();
sobelEdgeDetector.OutlineEdges(@"E:\Users\Me\Pictures\Error.jpg");
感谢
答
我有同样的问题,但我的库仔细研究后解决.. SobelEdgeDetector()所需要的灰度图片 所以你的代码将是
Private Image getEdge(Bitmap img)
{
Bitmap originalImage = img; //
// get grayscale image
originalImage = Grayscale.CommonAlgorithms.RMY.Apply(img);
// apply edge filter
IFilter ff = new SobelEdgeDetector();
Bitmap b = ff.Apply(originalImage);
originalImage.Dispose();
return (Image)b;
}
你可以显示你有什么'pathtoimage'?我甚至没有看到为此构造函数列出的ArgumentException;只有FileNotFoundException。 –
'pathtoimage'的价值是什么? –
在Image.FromFile()中记录了异常。有点,GDI +的例外情况相当薄弱。这张图片有多大? –