1+ // Copyright (c) Six Labors and contributors.
2+ // Licensed under the Apache License, Version 2.0.
3+
4+ using System . Numerics ;
5+ using System . Runtime . CompilerServices ;
6+
7+ using SixLabors . ImageSharp . PixelFormats ;
8+
9+ namespace SixLabors . ImageSharp
10+ {
11+ /// <content>
12+ /// Contains constructors and implicit conversion methods.
13+ /// </content>
14+ public readonly partial struct Color
15+ {
16+ /// <summary>
17+ /// Initializes a new instance of the <see cref="Color"/> struct.
18+ /// </summary>
19+ /// <param name="pixel">The <see cref="Rgba64"/> containing the color information.</param>
20+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
21+ public Color ( Rgba64 pixel ) => this . data = pixel ;
22+
23+ /// <summary>
24+ /// Initializes a new instance of the <see cref="Color"/> struct.
25+ /// </summary>
26+ /// <param name="pixel">The <see cref="Rgba32"/> containing the color information.</param>
27+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
28+ public Color ( Rgba32 pixel ) => this . data = new Rgba64 ( pixel ) ;
29+
30+ /// <summary>
31+ /// Initializes a new instance of the <see cref="Color"/> struct.
32+ /// </summary>
33+ /// <param name="pixel">The <see cref="Argb32"/> containing the color information.</param>
34+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
35+ public Color ( Argb32 pixel ) => this . data = new Rgba64 ( pixel ) ;
36+
37+ /// <summary>
38+ /// Initializes a new instance of the <see cref="Color"/> struct.
39+ /// </summary>
40+ /// <param name="pixel">The <see cref="Bgra32"/> containing the color information.</param>
41+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
42+ public Color ( Bgra32 pixel ) => this . data = new Rgba64 ( pixel ) ;
43+
44+ /// <summary>
45+ /// Initializes a new instance of the <see cref="Color"/> struct.
46+ /// </summary>
47+ /// <param name="pixel">The <see cref="Rgb24"/> containing the color information.</param>
48+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
49+ public Color ( Rgb24 pixel ) => this . data = new Rgba64 ( pixel ) ;
50+
51+ /// <summary>
52+ /// Initializes a new instance of the <see cref="Color"/> struct.
53+ /// </summary>
54+ /// <param name="pixel">The <see cref="Bgr24"/> containing the color information.</param>
55+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
56+ public Color ( Bgr24 pixel ) => this . data = new Rgba64 ( pixel ) ;
57+
58+ /// <summary>
59+ /// Initializes a new instance of the <see cref="Color"/> struct.
60+ /// </summary>
61+ /// <param name="vector">The <see cref="Vector4"/> containing the color information.</param>
62+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
63+ public Color ( Vector4 vector ) => this . data = new Rgba64 ( vector ) ;
64+
65+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
66+ internal Rgba64 ToRgba64 ( ) => this . data ;
67+
68+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
69+ internal Rgba32 ToRgba32 ( ) => this . data . ToRgba32 ( ) ;
70+
71+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
72+ internal Bgra32 ToBgra32 ( ) => this . data . ToBgra32 ( ) ;
73+
74+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
75+ internal Argb32 ToArgb32 ( ) => this . data . ToArgb32 ( ) ;
76+
77+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
78+ internal Rgb24 ToRgb24 ( ) => this . data . ToRgb24 ( ) ;
79+
80+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
81+ internal Bgr24 ToBgr24 ( ) => this . data . ToBgr24 ( ) ;
82+ }
83+ }
0 commit comments