xtd 1.0.0
Loading...
Searching...
No Matches
argb.hpp
Go to the documentation of this file.
1
4#pragma once
5#include <xtd/byte>
6#include <xtd/string>
7#include <xtd/uint32>
8
10namespace xtd {
12 namespace drawing {
22 struct argb {
24
28 xtd::byte a = 255;
39
41
45 [[nodiscard]] auto to_uint32() const noexcept -> xtd::uint32 {
46 return (static_cast<xtd::uint32>(a) << 24) + (static_cast<xtd::uint32>(r) << 16) + (static_cast<xtd::uint32>(g) << 8) + static_cast<xtd::uint32>(b);
47 }
48
49
51
55 [[nodiscard]] operator xtd::uint32() const noexcept {
56 return to_uint32();
57 }
58
59
61
69 [[nodiscard]] static auto from_argb(xtd::byte a, xtd::byte r, xtd::byte g, xtd::byte b) noexcept -> xtd::drawing::argb {
70 return argb {.a = a, .r = r, .g = g, .b = b};
71 }
72
75 [[nodiscard]] static auto from_argb(const argb& value) noexcept -> xtd::drawing::argb {
76 return value;
77 }
78
82 [[nodiscard]] static auto from_uint32(uint32 value) noexcept -> xtd::drawing::argb {
83 return argb {.a = static_cast<xtd::byte>((value & 0xFF000000) >> 24), .r = static_cast<xtd::byte>((value & 0x00FF0000) >> 16), .g = static_cast<xtd::byte>((value & 0x0000FF00) >> 8), .b = static_cast<xtd::byte>(value & 0x000000FF)};
84 }
85
86
88 friend auto operator <<(std::ostream& os, const argb& value) -> std::ostream& {
89 return os << xtd::string::format("argb [a = {}, r = {}, g = {}, b = {}]", value.a, value.r, value.g, value.b);
90 };
92 };
93 }
94}
static auto format(const basic_string< char > &fmt, args_t &&... args) -> basic_string
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
std::uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
The argb struct.
Definition argb.hpp:22
static auto from_argb(const argb &value) noexcept -> xtd::drawing::argb
Creates a xtd::argb struct from the specified axtd::drawing::argb value.
Definition argb.hpp:75
static auto from_argb(xtd::byte a, xtd::byte r, xtd::byte g, xtd::byte b) noexcept -> xtd::drawing::argb
Creates a xtd::argb struct from the specified a, r, g, and b byte values.
Definition argb.hpp:69
auto to_uint32() const noexcept -> xtd::uint32
Gets the 32-bit ARGB value of this xtd::drawing::argb struct.
Definition argb.hpp:45
static auto from_uint32(uint32 value) noexcept -> xtd::drawing::argb
Creates a xtd::argb struct from the specified unsigned integer value.
Definition argb.hpp:82
xtd::byte a
Gets or sets the alpha component value of this xtd::drawing::argb struct.
Definition argb.hpp:28
operator xtd::uint32() const noexcept
Gets the 32-bit ARGB value of this xtd::drawing::argb struct.
Definition argb.hpp:55
xtd::byte g
Gets or sets the green component value of this xtd::drawing::argb struct.
Definition argb.hpp:34
xtd::byte r
Gets or sets the red component value of this xtd::drawing::argb struct.
Definition argb.hpp:31
xtd::byte b
Gets or sets the blue component value of this xtd::drawing::argb struct.
Definition argb.hpp:37