Browse Source

Fixing Qoi detector

-I had several errors about header size comparison and comparing byte arrays, but I've fixed them and tested the Identify function and it works perfect!
qoi
LuisAlfredo92 3 years ago
parent
commit
a1342bf30a
No known key found for this signature in database GPG Key ID: 13A8436905993B8F
  1. 2
      src/ImageSharp/Formats/Qoi/QoiImageFormatDetector.cs
  2. 1
      tests/ImageSharp.Tests/Formats/Qoi/QoiDecoderTests.cs

2
src/ImageSharp/Formats/Qoi/QoiImageFormatDetector.cs

@ -23,5 +23,5 @@ public class QoiImageFormatDetector : IImageFormatDetector
}
private bool IsSupportedFileFormat(ReadOnlySpan<byte> header)
=> header.Length == this.HeaderSize && header[..4] == QoiConstants.Magic;
=> header.Length >= this.HeaderSize && QoiConstants.Magic.SequenceEqual(header[..4]);
}

1
tests/ImageSharp.Tests/Formats/Qoi/QoiDecoderTests.cs

@ -24,5 +24,6 @@ public class QoiDecoderTests
ImageInfo imageInfo = Image.Identify(stream);
Assert.NotNull(imageInfo);
Assert.Equal(imageInfo.Metadata.DecodedImageFormat, ImageSharp.Formats.Qoi.QoiFormat.Instance);
}
}

Loading…
Cancel
Save