HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
srgb_abgr8_pack.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2020-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
9#pragma once
10
11#include "sfloat_rgba16.hpp"
12#include "../color/color.hpp"
13#include "../macros.hpp"
14#include <algorithm>
15#include <array>
16#include <bit>
17#include <cstdint>
18
19hi_export_module(hikogui.image.srgb_abgr8_pack);
20
21hi_export namespace hi::inline v1 {
22
28 uint32_t v = {};
29
30public:
31 constexpr srgb_abgr8_pack() = default;
32 constexpr srgb_abgr8_pack(srgb_abgr8_pack const &rhs) noexcept = default;
33 constexpr srgb_abgr8_pack(srgb_abgr8_pack &&rhs) noexcept = default;
34 constexpr srgb_abgr8_pack &operator=(srgb_abgr8_pack const &rhs) noexcept = default;
35 constexpr srgb_abgr8_pack &operator=(srgb_abgr8_pack &&rhs) noexcept = default;
36
37 constexpr srgb_abgr8_pack(uint32_t const &rhs) noexcept : v(rhs) {}
38 constexpr srgb_abgr8_pack &operator=(uint32_t const &rhs) noexcept
39 {
40 v = rhs;
41 return *this;
42 }
43 constexpr operator uint32_t() noexcept
44 {
45 return v;
46 }
47
48 //constexpr srgb_abgr8_pack(sfloat_rgba16 const &rhs) noexcept
49 //{
50 // auto const &rhs_v = rhs.get();
51 //
52 // auto const r = sRGB_linear16_to_gamma8(rhs_v[0].get());
53 // auto const g = sRGB_linear16_to_gamma8(rhs_v[1].get());
54 // auto const b = sRGB_linear16_to_gamma8(rhs_v[2].get());
55 // auto const a = static_cast<uint8_t>(std::clamp(rhs_v[3] * 255.0f, 0.0f, 255.0f));
56 // v = (static_cast<uint32_t>(a) << 24) | (static_cast<uint32_t>(b) << 16) | (static_cast<uint32_t>(g) << 8) |
57 // static_cast<uint32_t>(r);
58 //}
59
60 //constexpr srgb_abgr8_pack &operator=(sfloat_rgba16 const &rhs) noexcept
61 //{
62 // auto const &rhs_v = rhs.get();
63 //
64 // auto const r = sRGB_linear16_to_gamma8(rhs_v[0]);
65 // auto const g = sRGB_linear16_to_gamma8(rhs_v[1]);
66 // auto const b = sRGB_linear16_to_gamma8(rhs_v[2]);
67 // auto const a = static_cast<uint8_t>(std::clamp(rhs_v[3] * 255.0f, 0.0f, 255.0f));
68 // v = (static_cast<uint32_t>(a) << 24) | (static_cast<uint32_t>(b) << 16) | (static_cast<uint32_t>(g) << 8) |
69 // static_cast<uint32_t>(r);
70 // return *this;
71 //}
72
73 [[nodiscard]] constexpr friend bool operator==(srgb_abgr8_pack const &lhs, srgb_abgr8_pack const &rhs) noexcept = default;
74
75 [[nodiscard]] constexpr friend srgb_abgr8_pack makeTransparent(srgb_abgr8_pack const &rhs) noexcept
76 {
77 return {rhs.v & 0x00ffffff};
78 }
79};
80
81//inline void fill(pixmap<srgb_abgr8_pack> &dst, pixmap<sfloat_rgba16> const &src) noexcept
82//{
83// hi_assert(dst.width >= src.width);
84// hi_assert(dst.height >= src.height);
85//
86// for (auto rowNr = 0; rowNr < src.height; rowNr++) {
87// auto const srcRow = src.at(rowNr);
88// auto dstRow = dst.at(rowNr);
89// for (auto columnNr = 0; columnNr < src.width; columnNr++) {
90// dstRow[columnNr] = srcRow[columnNr];
91// }
92// }
93//}
94
95} // namespace hi::inline v1
Defines the sfloat_rgba16.
Defined the color type.
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
4 x uint8_t pixel packed format with sRGB transfer function.
Definition srgb_abgr8_pack.hpp:27