File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,42 @@ namespace libscratchcpp
1010/* ! A typedef for unsigned int. Holds the RGBA values. */
1111using Rgb = unsigned int ;
1212
13+ /* ! Returns the red component of the quadruplet rgb. */
14+ inline constexpr int red (Rgb rgb)
15+ {
16+ return ((rgb >> 16 ) & 0xff );
17+ }
18+
19+ /* ! Returns the green component of the quadruplet rgb. */
20+ inline constexpr int green (Rgb rgb)
21+ {
22+ return ((rgb >> 8 ) & 0xff );
23+ }
24+
25+ /* ! Returns the blue component of the quadruplet rgb. */
26+ inline constexpr int blue (Rgb rgb)
27+ {
28+ return (rgb & 0xff );
29+ }
30+
31+ /* ! Returns the alpha component of the quadruplet rgb. */
32+ inline constexpr int alpha (Rgb rgb)
33+ {
34+ return rgb >> 24 ;
35+ }
36+
37+ /* ! Creates an RGB triplet from the given color components. */
38+ inline constexpr Rgb rgb (int r, int g, int b)
39+ {
40+ return (0xffu << 24 ) | ((r & 0xffu ) << 16 ) | ((g & 0xffu ) << 8 ) | (b & 0xffu );
41+ }
42+
43+ /* ! Creates an RGBA quadruplet from the given color components. */
44+ inline constexpr Rgb rgba (int r, int g, int b, int a)
45+ {
46+ return ((a & 0xffu ) << 24 ) | ((r & 0xffu ) << 16 ) | ((g & 0xffu ) << 8 ) | (b & 0xffu );
47+ }
48+
1349/* ! \brief The IImageFormat class is an interface for image format implementation. */
1450class LIBSCRATCHCPP_EXPORT IImageFormat
1551{
You can’t perform that action at this time.
0 commit comments