|
4 | 4 | using System.Runtime.CompilerServices; |
5 | 5 | using SixLabors.ImageSharp.PixelFormats; |
6 | 6 |
|
7 | | -// TODO: Review this class as it's used to represent 2 different things. |
| 7 | +// TODO: Review this type as it's used to represent 2 different things. |
8 | 8 | // 1.The encoded image pixel format. |
9 | 9 | // 2. The pixel format of the decoded image. |
10 | 10 | namespace SixLabors.ImageSharp.Formats; |
11 | 11 |
|
12 | 12 | /// <summary> |
13 | 13 | /// Contains information about the pixels that make up an images visual data. |
14 | 14 | /// </summary> |
15 | | -public readonly struct PixelTypeInfo |
| 15 | +/// <remarks> |
| 16 | +/// Initializes a new instance of the <see cref="PixelTypeInfo"/> struct. |
| 17 | +/// </remarks> |
| 18 | +/// <param name="bitsPerPixel">Color depth, in number of bits per pixel.</param> |
| 19 | +public readonly struct PixelTypeInfo(int bitsPerPixel) |
16 | 20 | { |
17 | | - /// <summary> |
18 | | - /// Initializes a new instance of the <see cref="PixelTypeInfo"/> struct. |
19 | | - /// </summary> |
20 | | - /// <param name="bitsPerPixel">Color depth, in number of bits per pixel.</param> |
21 | | - public PixelTypeInfo(int bitsPerPixel) |
22 | | - => this.BitsPerPixel = bitsPerPixel; |
23 | | - |
24 | 21 | /// <summary> |
25 | 22 | /// Gets color depth, in number of bits per pixel. |
26 | 23 | /// </summary> |
27 | | - public int BitsPerPixel { get; init; } |
| 24 | + public int BitsPerPixel { get; init; } = bitsPerPixel; |
28 | 25 |
|
29 | 26 | /// <summary> |
30 | 27 | /// Gets the count of the color components |
31 | 28 | /// </summary> |
32 | 29 | public byte ComponentCount { get; init; } |
33 | 30 |
|
| 31 | + /// <summary> |
| 32 | + /// Gets the pixel component precision. |
| 33 | + /// </summary> |
| 34 | + public PixelComponentPrecision? ComponentPrecision { get; init; } |
| 35 | + |
34 | 36 | /// <summary> |
35 | 37 | /// Gets the pixel alpha transparency behavior. |
36 | 38 | /// <see langword="null"/> means unknown, unspecified. |
37 | 39 | /// </summary> |
38 | 40 | public PixelAlphaRepresentation? AlphaRepresentation { get; init; } |
39 | 41 |
|
40 | | - internal static PixelTypeInfo Create<TPixel>(byte componentCount, PixelAlphaRepresentation pixelAlphaRepresentation) |
| 42 | + internal static PixelTypeInfo Create<TPixel>( |
| 43 | + byte componentCount, |
| 44 | + PixelComponentPrecision componentPrecision, |
| 45 | + PixelAlphaRepresentation pixelAlphaRepresentation) |
41 | 46 | where TPixel : unmanaged, IPixel<TPixel> |
42 | 47 | => new() |
43 | 48 | { |
44 | 49 | BitsPerPixel = Unsafe.SizeOf<TPixel>() * 8, |
45 | 50 | ComponentCount = componentCount, |
| 51 | + ComponentPrecision = componentPrecision, |
46 | 52 | AlphaRepresentation = pixelAlphaRepresentation |
47 | 53 | }; |
48 | 54 | } |
0 commit comments