Skip to content

Commit 1d35251

Browse files
Add PixelColorType
1 parent 6b6b474 commit 1d35251

Some content is hidden

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

62 files changed

+239
-32
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
namespace SixLabors.ImageSharp.PixelFormats;
5+
6+
/// <summary>
7+
/// Represents the color type and format of a pixel.
8+
/// </summary>
9+
[Flags]
10+
public enum PixelColorType
11+
{
12+
/// <summary>
13+
/// Represents the Red component of the color.
14+
/// </summary>
15+
Red = 1 << 0,
16+
17+
/// <summary>
18+
/// Represents the Green component of the color.
19+
/// </summary>
20+
Green = 1 << 1,
21+
22+
/// <summary>
23+
/// Represents the Blue component of the color.
24+
/// </summary>
25+
Blue = 1 << 2,
26+
27+
/// <summary>
28+
/// Represents the Alpha component of the color for transparency.
29+
/// </summary>
30+
Alpha = 1 << 3,
31+
32+
/// <summary>
33+
/// Indicates that the color is in grayscale.
34+
/// </summary>
35+
Grayscale = 1 << 4,
36+
37+
/// <summary>
38+
/// Indicates that the color is in RGB (Red, Green, Blue) format.
39+
/// </summary>
40+
RGB = Red | Green | Blue | (1 << 5),
41+
42+
/// <summary>
43+
/// Indicates that the color is in BGR (Blue, Green, Red) format.
44+
/// </summary>
45+
BGR = Blue | Green | Red | (1 << 6)
46+
}

src/ImageSharp/PixelFormats/PixelImplementations/A8.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ public partial struct A8 : IPixel<A8>, IPackedVector<byte>
5656
public static bool operator !=(A8 left, A8 right) => !left.Equals(right);
5757

5858
/// <inheritdoc/>
59-
public static PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<A8>(PixelComponentInfo.Create<A8>(1, 8), PixelAlphaRepresentation.Unassociated);
59+
public static PixelTypeInfo GetPixelTypeInfo()
60+
=> PixelTypeInfo.Create<A8>(
61+
PixelComponentInfo.Create<A8>(1, 8),
62+
PixelColorType.Alpha,
63+
PixelAlphaRepresentation.Unassociated);
6064

6165
/// <inheritdoc />
6266
public readonly PixelOperations<A8> CreatePixelOperations() => new PixelOperations();

src/ImageSharp/PixelFormats/PixelImplementations/Abgr32.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ public uint PackedValue
168168
public static bool operator !=(Abgr32 left, Abgr32 right) => !left.Equals(right);
169169

170170
/// <inheritdoc />
171-
public static PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Abgr32>(PixelComponentInfo.Create<Abgr32>(4, 8, 8, 8, 8), PixelAlphaRepresentation.Unassociated);
171+
public static PixelTypeInfo GetPixelTypeInfo()
172+
=> PixelTypeInfo.Create<Abgr32>(
173+
PixelComponentInfo.Create<Abgr32>(4, 8, 8, 8, 8),
174+
PixelColorType.Alpha | PixelColorType.BGR,
175+
PixelAlphaRepresentation.Unassociated);
172176

173177
/// <inheritdoc />
174178
public readonly PixelOperations<Abgr32> CreatePixelOperations() => new PixelOperations();

src/ImageSharp/PixelFormats/PixelImplementations/Argb32.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ public uint PackedValue
168168
public static bool operator !=(Argb32 left, Argb32 right) => !left.Equals(right);
169169

170170
/// <inheritdoc />
171-
public static PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Argb32>(PixelComponentInfo.Create<Argb32>(4, 8, 8, 8, 8), PixelAlphaRepresentation.Unassociated);
171+
public static PixelTypeInfo GetPixelTypeInfo()
172+
=> PixelTypeInfo.Create<Argb32>(
173+
PixelComponentInfo.Create<Argb32>(4, 8, 8, 8, 8),
174+
PixelColorType.Alpha | PixelColorType.RGB,
175+
PixelAlphaRepresentation.Unassociated);
172176

173177
/// <inheritdoc />
174178
public readonly PixelOperations<Argb32> CreatePixelOperations() => new PixelOperations();

src/ImageSharp/PixelFormats/PixelImplementations/Bgr24.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ public Bgr24(byte r, byte g, byte b)
7272
public static bool operator !=(Bgr24 left, Bgr24 right) => !left.Equals(right);
7373

7474
/// <inheritdoc />
75-
public static PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgr24>(PixelComponentInfo.Create<Bgr24>(3, 8, 8, 8), PixelAlphaRepresentation.None);
75+
public static PixelTypeInfo GetPixelTypeInfo()
76+
=> PixelTypeInfo.Create<Bgr24>(
77+
PixelComponentInfo.Create<Bgr24>(3, 8, 8, 8),
78+
PixelColorType.BGR,
79+
PixelAlphaRepresentation.None);
7680

7781
/// <inheritdoc/>
7882
public readonly PixelOperations<Bgr24> CreatePixelOperations() => new PixelOperations();

src/ImageSharp/PixelFormats/PixelImplementations/Bgr565.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ public Bgr565(float x, float y, float z)
6060
public static bool operator !=(Bgr565 left, Bgr565 right) => !left.Equals(right);
6161

6262
/// <inheritdoc />
63-
public static PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgr565>(PixelComponentInfo.Create<Bgr565>(3, 5, 6, 5), PixelAlphaRepresentation.None);
63+
public static PixelTypeInfo GetPixelTypeInfo()
64+
=> PixelTypeInfo.Create<Bgr565>(
65+
PixelComponentInfo.Create<Bgr565>(3, 5, 6, 5),
66+
PixelColorType.BGR,
67+
PixelAlphaRepresentation.None);
6468

6569
/// <inheritdoc />
6670
public readonly PixelOperations<Bgr565> CreatePixelOperations() => new PixelOperations();

src/ImageSharp/PixelFormats/PixelImplementations/Bgra32.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ public uint PackedValue
121121
public static bool operator !=(Bgra32 left, Bgra32 right) => !left.Equals(right);
122122

123123
/// <inheritdoc />
124-
public static PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgra32>(PixelComponentInfo.Create<Bgra32>(4, 8, 8, 8, 8), PixelAlphaRepresentation.Unassociated);
124+
public static PixelTypeInfo GetPixelTypeInfo()
125+
=> PixelTypeInfo.Create<Bgra32>(
126+
PixelComponentInfo.Create<Bgra32>(4, 8, 8, 8, 8),
127+
PixelColorType.BGR | PixelColorType.Alpha,
128+
PixelAlphaRepresentation.Unassociated);
125129

126130
/// <inheritdoc/>
127131
public readonly PixelOperations<Bgra32> CreatePixelOperations() => new PixelOperations();

src/ImageSharp/PixelFormats/PixelImplementations/Bgra4444.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ public Bgra4444(float x, float y, float z, float w)
5858
public static bool operator !=(Bgra4444 left, Bgra4444 right) => !left.Equals(right);
5959

6060
/// <inheritdoc />
61-
public static PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgra4444>(PixelComponentInfo.Create<Bgra4444>(4, 4, 4, 4, 4), PixelAlphaRepresentation.Unassociated);
61+
public static PixelTypeInfo GetPixelTypeInfo()
62+
=> PixelTypeInfo.Create<Bgra4444>(
63+
PixelComponentInfo.Create<Bgra4444>(4, 4, 4, 4, 4),
64+
PixelColorType.BGR | PixelColorType.Alpha,
65+
PixelAlphaRepresentation.Unassociated);
6266

6367
/// <inheritdoc />
6468
public readonly PixelOperations<Bgra4444> CreatePixelOperations() => new PixelOperations();

src/ImageSharp/PixelFormats/PixelImplementations/Bgra5551.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ public Bgra5551(float x, float y, float z, float w)
6161
public static bool operator !=(Bgra5551 left, Bgra5551 right) => !left.Equals(right);
6262

6363
/// <inheritdoc />
64-
public static PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Bgra5551>(PixelComponentInfo.Create<Bgra5551>(4, 5, 5, 5, 1), PixelAlphaRepresentation.Unassociated);
64+
public static PixelTypeInfo GetPixelTypeInfo()
65+
=> PixelTypeInfo.Create<Bgra5551>(
66+
PixelComponentInfo.Create<Bgra5551>(4, 5, 5, 5, 1),
67+
PixelColorType.BGR | PixelColorType.Alpha,
68+
PixelAlphaRepresentation.Unassociated);
6569

6670
/// <inheritdoc />
6771
public readonly PixelOperations<Bgra5551> CreatePixelOperations() => new PixelOperations();

src/ImageSharp/PixelFormats/PixelImplementations/Byte4.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ public Byte4(float x, float y, float z, float w)
6161
public static bool operator !=(Byte4 left, Byte4 right) => !left.Equals(right);
6262

6363
/// <inheritdoc />
64-
public static PixelTypeInfo GetPixelTypeInfo() => PixelTypeInfo.Create<Byte4>(PixelComponentInfo.Create<Byte4>(4, 8, 8, 8, 8), PixelAlphaRepresentation.Unassociated);
64+
public static PixelTypeInfo GetPixelTypeInfo()
65+
=> PixelTypeInfo.Create<Byte4>(
66+
PixelComponentInfo.Create<Byte4>(4, 8, 8, 8, 8),
67+
PixelColorType.RGB | PixelColorType.Alpha,
68+
PixelAlphaRepresentation.Unassociated);
6569

6670
/// <inheritdoc />
6771
public readonly PixelOperations<Byte4> CreatePixelOperations() => new PixelOperations();

0 commit comments

Comments
 (0)