JPG.zip (415.6 KB)
有两张图片是有问题的,但是不知道怎么能把它们都检测出来确实是有问题的照片呢!我用C#写的,之前用下面这段代码都不管用了,不知道是怎么回事呢,请大神帮忙看看,谢谢!
public void TestJpeg()
{
using (RasterImage image = (RasterImage)Image.Load(“13.jpg”))
{
if (!IsContentCorrect(image))
{
Console.WriteLine(“Image is corrupted!”);
}
else
Console.WriteLine(“Image is OK!”);
}
}
private class EmptyProcessor : IPartialArgb32PixelLoader
{
public void Process(Rectangle pixelsRectangle, int[] pixels, Point start, Point end)
{
// do nothing, just to enforce loading the pixels from jpeg
}
}
private static bool IsContentCorrect(RasterImage image)
{
try
{
image.LoadPartialArgb32Pixels(image.Bounds, new EmptyProcessor());
}
catch
{
return false;
}
return true;
}