HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
hikogui
image
snorm_r8.hpp
Go to the documentation of this file.
1
// Copyright Take Vos 2021.
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 "../utility/module.hpp"
12
#include <algorithm>
13
14
namespace
hi::inline
v1
{
15
16
[[nodiscard]]
constexpr
int8_t make_snorm_r8_value(
float
rhs)
noexcept
17
{
18
return
round_cast<int8_t>(std::clamp(rhs, -1.0f, 1.0f) * 127.0f);
19
}
20
25
struct
snorm_r8
{
26
int8_t value;
27
28
snorm_r8
() =
default
;
29
snorm_r8
(
snorm_r8
const
&rhs)
noexcept
=
default
;
30
snorm_r8
(
snorm_r8
&&rhs)
noexcept
=
default
;
31
snorm_r8
&operator=(
snorm_r8
const
&rhs)
noexcept
=
default
;
32
snorm_r8
&operator=(
snorm_r8
&&rhs)
noexcept
=
default
;
33
~snorm_r8
() =
default
;
34
35
explicit
snorm_r8
(
float
rhs) noexcept : value(make_snorm_r8_value(rhs)) {}
36
37
snorm_r8
&operator=(
float
rhs)
noexcept
38
{
39
value = make_snorm_r8_value(rhs);
40
return
*
this
;
41
}
42
43
explicit
operator
float()
const
noexcept
44
{
45
return
narrow_cast<float>(value) / 127.0f;
46
}
47
};
48
49
}
// namespace hi::inline v1
v1
DOXYGEN BUG.
Definition
algorithm.hpp:13
v1::snorm_r8
1 x int8_t pixel format.
Definition
snorm_r8.hpp:25
Generated on Mon Apr 22 2024 12:52:51 for HikoGUI by
1.10.0