|
| 1 | +// Copyright (c) Six Labors. |
| 2 | +// Licensed under the Six Labors Split License. |
| 3 | + |
| 4 | +using System.Diagnostics.CodeAnalysis; |
| 5 | +using SixLabors.ImageSharp.Metadata; |
| 6 | + |
| 7 | +namespace SixLabors.ImageSharp.Formats.Icon.Cur; |
| 8 | + |
| 9 | +/// <summary> |
| 10 | +/// Extension methods for the <see cref="ImageMetadata"/> type. |
| 11 | +/// </summary> |
| 12 | +public static class MetadataExtensions |
| 13 | +{ |
| 14 | + /// <summary> |
| 15 | + /// Gets the Icon format specific metadata for the image. |
| 16 | + /// </summary> |
| 17 | + /// <param name="source">The metadata this method extends.</param> |
| 18 | + /// <returns>The <see cref="CurMetadata"/>.</returns> |
| 19 | + public static CurMetadata GetCurMetadata(this ImageMetadata source) |
| 20 | + => source.GetFormatMetadata(CurFormat.Instance); |
| 21 | + |
| 22 | + /// <summary> |
| 23 | + /// Gets the Icon format specific metadata for the image frame. |
| 24 | + /// </summary> |
| 25 | + /// <param name="source">The metadata this method extends.</param> |
| 26 | + /// <returns>The <see cref="CurFrameMetadata"/>.</returns> |
| 27 | + public static CurFrameMetadata GetCurMetadata(this ImageFrameMetadata source) |
| 28 | + => source.GetFormatMetadata(CurFormat.Instance); |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// Gets the Icon format specific metadata for the image frame. |
| 32 | + /// </summary> |
| 33 | + /// <param name="source">The metadata this method extends.</param> |
| 34 | + /// <param name="metadata"> |
| 35 | + /// When this method returns, contains the metadata associated with the specified frame, |
| 36 | + /// if found; otherwise, the default value for the type of the metadata parameter. |
| 37 | + /// This parameter is passed uninitialized. |
| 38 | + /// </param> |
| 39 | + /// <returns> |
| 40 | + /// <see langword="true"/> if the Icon frame metadata exists; otherwise, <see langword="false"/>. |
| 41 | + /// </returns> |
| 42 | + public static bool TryGetCurMetadata(this ImageFrameMetadata source, [NotNullWhen(true)] out CurFrameMetadata? metadata) |
| 43 | + => source.TryGetFormatMetadata(CurFormat.Instance, out metadata); |
| 44 | +} |
0 commit comments