Skip to content

Commit a1342bf

Browse files
committed
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!
1 parent 8b9e0a9 commit a1342bf

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/ImageSharp/Formats/Qoi/QoiImageFormatDetector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ public bool TryDetectFormat(ReadOnlySpan<byte> header, [NotNullWhen(true)] out I
2323
}
2424

2525
private bool IsSupportedFileFormat(ReadOnlySpan<byte> header)
26-
=> header.Length == this.HeaderSize && header[..4] == QoiConstants.Magic;
26+
=> header.Length >= this.HeaderSize && QoiConstants.Magic.SequenceEqual(header[..4]);
2727
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ public void Identify(string imagePath)
2424
ImageInfo imageInfo = Image.Identify(stream);
2525

2626
Assert.NotNull(imageInfo);
27+
Assert.Equal(imageInfo.Metadata.DecodedImageFormat, ImageSharp.Formats.Qoi.QoiFormat.Instance);
2728
}
2829
}

0 commit comments

Comments
 (0)