Skip to content

Commit 4b15595

Browse files
Merge branch 'main' into js/gif-fixes
2 parents ef08c82 + 900e9d0 commit 4b15595

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1435
-64
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
*.bmp filter=lfs diff=lfs merge=lfs -text
119119
*.gif filter=lfs diff=lfs merge=lfs -text
120120
*.png filter=lfs diff=lfs merge=lfs -text
121+
*.qoi filter=lfs diff=lfs merge=lfs -text
121122
*.tif filter=lfs diff=lfs merge=lfs -text
122123
*.tiff filter=lfs diff=lfs merge=lfs -text
123124
*.tga filter=lfs diff=lfs merge=lfs -text

ImageSharp.sln

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tga", "Tga", "{5DFC394F-136
646646
tests\Images\Input\Tga\targa_8bit_rle.tga = tests\Images\Input\Tga\targa_8bit_rle.tga
647647
EndProjectSection
648648
EndProject
649+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Qoi", "Qoi", "{E801B508-4935-41CD-BA85-CF11BFF55A45}"
650+
ProjectSection(SolutionItems) = preProject
651+
tests\Images\Input\Qoi\dice.qoi = tests\Images\Input\Qoi\dice.qoi
652+
tests\Images\Input\Qoi\edgecase.qoi = tests\Images\Input\Qoi\edgecase.qoi
653+
tests\Images\Input\Qoi\kodim10.qoi = tests\Images\Input\Qoi\kodim10.qoi
654+
tests\Images\Input\Qoi\kodim23.qoi = tests\Images\Input\Qoi\kodim23.qoi
655+
tests\Images\Input\Qoi\qoi_logo.qoi = tests\Images\Input\Qoi\qoi_logo.qoi
656+
tests\Images\Input\Qoi\testcard.qoi = tests\Images\Input\Qoi\testcard.qoi
657+
tests\Images\Input\Qoi\testcard_rgba.qoi = tests\Images\Input\Qoi\testcard_rgba.qoi
658+
tests\Images\Input\Qoi\wikipedia_008.qoi = tests\Images\Input\Qoi\wikipedia_008.qoi
659+
EndProjectSection
660+
EndProject
649661
Global
650662
GlobalSection(SolutionConfigurationPlatforms) = preSolution
651663
Debug|Any CPU = Debug|Any CPU
@@ -698,6 +710,7 @@ Global
698710
{FC527290-2F22-432C-B77B-6E815726B02C} = {56801022-D71A-4FBE-BC5B-CBA08E2284EC}
699711
{670DD46C-82E9-499A-B2D2-00A802ED0141} = {E1C42A6F-913B-4A7B-B1A8-2BB62843B254}
700712
{5DFC394F-136F-4B76-9BCA-3BA786515EFC} = {9DA226A1-8656-49A8-A58A-A8B5C081AD66}
713+
{E801B508-4935-41CD-BA85-CF11BFF55A45} = {9DA226A1-8656-49A8-A58A-A8B5C081AD66}
701714
EndGlobalSection
702715
GlobalSection(ExtensibilityGlobals) = postSolution
703716
SolutionGuid = {5F8B9D1F-CD8B-4CC5-8216-D531E25BD795}

src/ImageSharp/Common/Helpers/Numerics.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,30 @@ public static int LeastCommonMultiple(int a, int b)
7373
[MethodImpl(MethodImplOptions.AggressiveInlining)]
7474
public static nint Modulo8(nint x) => x & 7;
7575

76+
/// <summary>
77+
/// Calculates <paramref name="x"/> % 64
78+
/// </summary>
79+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
80+
public static int Modulo64(int x) => x & 63;
81+
82+
/// <summary>
83+
/// Calculates <paramref name="x"/> % 64
84+
/// </summary>
85+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
86+
public static nint Modulo64(nint x) => x & 63;
87+
88+
/// <summary>
89+
/// Calculates <paramref name="x"/> % 256
90+
/// </summary>
91+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
92+
public static int Modulo256(int x) => x & 255;
93+
94+
/// <summary>
95+
/// Calculates <paramref name="x"/> % 256
96+
/// </summary>
97+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
98+
public static nint Modulo256(nint x) => x & 255;
99+
76100
/// <summary>
77101
/// Fast (x mod m) calculator, with the restriction that
78102
/// <paramref name="m"/> should be power of 2.

src/ImageSharp/Configuration.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using SixLabors.ImageSharp.Formats.Jpeg;
99
using SixLabors.ImageSharp.Formats.Pbm;
1010
using SixLabors.ImageSharp.Formats.Png;
11+
using SixLabors.ImageSharp.Formats.Qoi;
1112
using SixLabors.ImageSharp.Formats.Tga;
1213
using SixLabors.ImageSharp.Formats.Tiff;
1314
using SixLabors.ImageSharp.Formats.Webp;
@@ -212,6 +213,7 @@ public void Configure(IImageFormatConfigurationModule configuration)
212213
/// <see cref="TgaConfigurationModule"/>.
213214
/// <see cref="TiffConfigurationModule"/>.
214215
/// <see cref="WebpConfigurationModule"/>.
216+
/// <see cref="QoiConfigurationModule"/>.
215217
/// </summary>
216218
/// <returns>The default configuration of <see cref="Configuration"/>.</returns>
217219
internal static Configuration CreateDefaultInstance() => new(
@@ -222,5 +224,6 @@ public void Configure(IImageFormatConfigurationModule configuration)
222224
new PbmConfigurationModule(),
223225
new TgaConfigurationModule(),
224226
new TiffConfigurationModule(),
225-
new WebpConfigurationModule());
227+
new WebpConfigurationModule(),
228+
new QoiConfigurationModule());
226229
}

src/ImageSharp/Formats/ImageExtensions.Save.cs

Lines changed: 154 additions & 51 deletions
Large diffs are not rendered by default.

src/ImageSharp/Formats/ImageExtensions.Save.tt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ using SixLabors.ImageSharp.Advanced;
1414
"Jpeg",
1515
"Pbm",
1616
"Png",
17+
"Qoi",
1718
"Tga",
18-
"Webp",
1919
"Tiff",
20+
"Webp",
2021
};
2122

2223
foreach (string fmt in formats)

src/ImageSharp/Formats/Jpeg/Components/Decoder/JFifMarker.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ private JFifMarker(byte majorVersion, byte minorVersion, byte densityUnits, shor
7171
/// <param name="marker">The marker to return.</param>
7272
public static bool TryParse(ReadOnlySpan<byte> bytes, out JFifMarker marker)
7373
{
74-
if (ProfileResolver.IsProfile(bytes, ProfileResolver.JFifMarker))
74+
// Some images incorrectly use JFXX as the App0 marker (Issue 2478)
75+
if (ProfileResolver.IsProfile(bytes, ProfileResolver.JFifMarker)
76+
|| ProfileResolver.IsProfile(bytes, ProfileResolver.JFxxMarker))
7577
{
7678
byte majorVersion = bytes[5];
7779
byte minorVersion = bytes[6];

src/ImageSharp/Formats/Jpeg/Components/Decoder/ProfileResolver.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ internal static class ProfileResolver
1616
(byte)'J', (byte)'F', (byte)'I', (byte)'F', (byte)'\0'
1717
};
1818

19+
/// <summary>
20+
/// Gets the JFXX specific markers.
21+
/// </summary>
22+
public static ReadOnlySpan<byte> JFxxMarker => new[]
23+
{
24+
(byte)'J', (byte)'F', (byte)'X', (byte)'X', (byte)'\0'
25+
};
26+
1927
/// <summary>
2028
/// Gets the ICC specific markers.
2129
/// </summary>

src/ImageSharp/Formats/Png/PngEncoderCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ internal sealed class PngEncoderCore : IImageEncoderInternals, IDisposable
3434
private readonly MemoryAllocator memoryAllocator;
3535

3636
/// <summary>
37-
/// The configuration instance for the decoding operation.
37+
/// The configuration instance for the encoding operation.
3838
/// </summary>
3939
private readonly Configuration configuration;
4040

0 commit comments

Comments
 (0)