|
9 | 9 | using SixLabors.ImageSharp.Formats.Jpeg;
|
10 | 10 | using SixLabors.ImageSharp.Formats.Pbm;
|
11 | 11 | using SixLabors.ImageSharp.Formats.Png;
|
| 12 | +using SixLabors.ImageSharp.Formats.Qoi; |
12 | 13 | using SixLabors.ImageSharp.Formats.Tga;
|
13 | 14 | using SixLabors.ImageSharp.Formats.Webp;
|
14 | 15 | using SixLabors.ImageSharp.Formats.Tiff;
|
@@ -836,4 +837,105 @@ public static Task SaveAsTiffAsync(this Image source, Stream stream, TiffEncoder
|
836 | 837 | encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(TiffFormat.Instance),
|
837 | 838 | cancellationToken);
|
838 | 839 |
|
| 840 | + /// <summary> |
| 841 | + /// Saves the image to the given stream with the Qoi format. |
| 842 | + /// </summary> |
| 843 | + /// <param name="source">The image this method extends.</param> |
| 844 | + /// <param name="path">The file path to save the image to.</param> |
| 845 | + /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception> |
| 846 | + public static void SaveAsQoi(this Image source, string path) => SaveAsQoi(source, path, default); |
| 847 | + |
| 848 | + /// <summary> |
| 849 | + /// Saves the image to the given stream with the Qoi format. |
| 850 | + /// </summary> |
| 851 | + /// <param name="source">The image this method extends.</param> |
| 852 | + /// <param name="path">The file path to save the image to.</param> |
| 853 | + /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception> |
| 854 | + /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 855 | + public static Task SaveAsQoiAsync(this Image source, string path) => SaveAsQoiAsync(source, path, default); |
| 856 | + |
| 857 | + /// <summary> |
| 858 | + /// Saves the image to the given stream with the Qoi format. |
| 859 | + /// </summary> |
| 860 | + /// <param name="source">The image this method extends.</param> |
| 861 | + /// <param name="path">The file path to save the image to.</param> |
| 862 | + /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> |
| 863 | + /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception> |
| 864 | + /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 865 | + public static Task SaveAsQoiAsync(this Image source, string path, CancellationToken cancellationToken) |
| 866 | + => SaveAsQoiAsync(source, path, default, cancellationToken); |
| 867 | + |
| 868 | + /// <summary> |
| 869 | + /// Saves the image to the given stream with the Qoi format. |
| 870 | + /// </summary> |
| 871 | + /// <param name="source">The image this method extends.</param> |
| 872 | + /// <param name="path">The file path to save the image to.</param> |
| 873 | + /// <param name="encoder">The encoder to save the image with.</param> |
| 874 | + /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception> |
| 875 | + public static void SaveAsQoi(this Image source, string path, QoiEncoder encoder) => |
| 876 | + source.Save( |
| 877 | + path, |
| 878 | + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance)); |
| 879 | + |
| 880 | + /// <summary> |
| 881 | + /// Saves the image to the given stream with the Qoi format. |
| 882 | + /// </summary> |
| 883 | + /// <param name="source">The image this method extends.</param> |
| 884 | + /// <param name="path">The file path to save the image to.</param> |
| 885 | + /// <param name="encoder">The encoder to save the image with.</param> |
| 886 | + /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> |
| 887 | + /// <exception cref="System.ArgumentNullException">Thrown if the path is null.</exception> |
| 888 | + /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 889 | + public static Task SaveAsQoiAsync(this Image source, string path, QoiEncoder encoder, CancellationToken cancellationToken = default) |
| 890 | + => source.SaveAsync( |
| 891 | + path, |
| 892 | + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance), |
| 893 | + cancellationToken); |
| 894 | + |
| 895 | + /// <summary> |
| 896 | + /// Saves the image to the given stream with the Qoi format. |
| 897 | + /// </summary> |
| 898 | + /// <param name="source">The image this method extends.</param> |
| 899 | + /// <param name="stream">The stream to save the image to.</param> |
| 900 | + /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception> |
| 901 | + public static void SaveAsQoi(this Image source, Stream stream) |
| 902 | + => SaveAsQoi(source, stream, default); |
| 903 | + |
| 904 | + /// <summary> |
| 905 | + /// Saves the image to the given stream with the Qoi format. |
| 906 | + /// </summary> |
| 907 | + /// <param name="source">The image this method extends.</param> |
| 908 | + /// <param name="stream">The stream to save the image to.</param> |
| 909 | + /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> |
| 910 | + /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception> |
| 911 | + /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 912 | + public static Task SaveAsQoiAsync(this Image source, Stream stream, CancellationToken cancellationToken = default) |
| 913 | + => SaveAsQoiAsync(source, stream, default, cancellationToken); |
| 914 | + |
| 915 | + /// <summary> |
| 916 | + /// Saves the image to the given stream with the Qoi format. |
| 917 | + /// </summary> |
| 918 | + /// <param name="source">The image this method extends.</param> |
| 919 | + /// <param name="stream">The stream to save the image to.</param> |
| 920 | + /// <param name="encoder">The encoder to save the image with.</param> |
| 921 | + /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception> |
| 922 | + public static void SaveAsQoi(this Image source, Stream stream, QoiEncoder encoder) |
| 923 | + => source.Save( |
| 924 | + stream, |
| 925 | + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance)); |
| 926 | + |
| 927 | + /// <summary> |
| 928 | + /// Saves the image to the given stream with the Qoi format. |
| 929 | + /// </summary> |
| 930 | + /// <param name="source">The image this method extends.</param> |
| 931 | + /// <param name="stream">The stream to save the image to.</param> |
| 932 | + /// <param name="encoder">The encoder to save the image with.</param> |
| 933 | + /// <param name="cancellationToken">The token to monitor for cancellation requests.</param> |
| 934 | + /// <exception cref="System.ArgumentNullException">Thrown if the stream is null.</exception> |
| 935 | + /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |
| 936 | + public static Task SaveAsQoiAsync(this Image source, Stream stream, QoiEncoder encoder, CancellationToken cancellationToken = default) |
| 937 | + => source.SaveAsync( |
| 938 | + stream, |
| 939 | + encoder ?? source.GetConfiguration().ImageFormatsManager.GetEncoder(QoiFormat.Instance), |
| 940 | + cancellationToken); |
839 | 941 | }
|
0 commit comments