MEPP2 Project
FEVV
Tools
Math
color_conversion.hpp
Go to the documentation of this file.
1
// Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2
// All rights reserved.
3
//
4
// This file is part of MEPP2; you can redistribute it and/or modify
5
// it under the terms of the GNU Lesser General Public License as
6
// published by the Free Software Foundation; either version 3 of
7
// the License, or (at your option) any later version.
8
//
9
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11
#pragma once
12
13
#include <cstdint>
// for uint8_t
14
15
16
namespace
FEVV
{
17
namespace
Math {
18
19
20
// Note: it is assumed that color value is either a 8 bits unsigned int value in
21
// range [0; 255], or a floating point value in range [0.0; 1.0].
22
23
28
template
<
typename
OutT >
29
OutT
convert_color_value
(uint8_t color_0_255)
30
{
31
return
static_cast<
OutT
>
(color_0_255);
32
}
33
37
template
<>
38
inline
39
float
convert_color_value< float >
(uint8_t color_0_255)
40
{
41
return
color_0_255 / 255.0f;
42
}
43
47
template
<>
48
inline
49
double
convert_color_value< double >
(uint8_t color_0_255)
50
{
51
return
color_0_255 / 255.0;
52
}
53
58
template
<
typename
OutT >
59
OutT
convert_color_value
(
double
color_0_1)
60
{
61
return
static_cast<
OutT
>
(color_0_1);
62
}
63
67
template
<>
68
inline
69
uint8_t
convert_color_value< uint8_t >
(
double
color_0_1)
70
{
71
// note: applies also to color_0_1 of type float
72
return
static_cast<
uint8_t
>
(color_0_1 * 255.0);
73
}
74
75
76
}
// namespace Math
77
}
// namespace FEVV
FEVV::Math::convert_color_value< uint8_t >
uint8_t convert_color_value< uint8_t >(double color_0_1)
Definition:
color_conversion.hpp:69
FEVV::Math::convert_color_value< double >
double convert_color_value< double >(uint8_t color_0_255)
Definition:
color_conversion.hpp:49
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition:
Assert.h:16
FEVV::Math::convert_color_value< float >
float convert_color_value< float >(uint8_t color_0_255)
Definition:
color_conversion.hpp:39
FEVV::Math::convert_color_value
OutT convert_color_value(uint8_t color_0_255)
Definition:
color_conversion.hpp:29
Generated by
1.8.20