-
Notifications
You must be signed in to change notification settings - Fork 0
/
Conversion.h
118 lines (101 loc) · 2.74 KB
/
Conversion.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef RGB_CONVERTER_H
#define RGB_CONVERTER_H
#define _USE_MATH_DEFINES
#include <cmath>
#include <algorithm>
#include "Utils.h"
namespace ColorSpace {
struct Rgb;
struct Xyz;
struct Hsl;
struct Lab;
struct Lch;
struct Luv;
struct Yxy;
struct Cmy;
struct Cmyk;
struct Hsv;
struct Hsb;
struct HunterLab;
template <typename TColorSpace>
struct IConverter {
static void ToColorSpace(Rgb *color, TColorSpace *item);
static void ToColor(Rgb *color, TColorSpace *item);
};
template <>
struct IConverter<Rgb> {
static void ToColorSpace(Rgb *color, Rgb *item);
static void ToColor(Rgb *color, Rgb *item);
};
typedef IConverter<Rgb> RgbConverter;
template <>
struct IConverter<Xyz> {
static void ToColorSpace(Rgb *color, Xyz *item);
static void ToColor(Rgb *color, Xyz *item);
static const double eps;
static const double kappa;
static const Xyz whiteReference;
};
typedef IConverter<Xyz> XyzConverter;
template <>
struct IConverter<Hsl> {
static void ToColorSpace(Rgb *color, Hsl *item);
static void ToColor(Rgb *color, Hsl *item);
};
typedef IConverter<Hsl> HslConverter;
template <>
struct IConverter<Lab> {
static void ToColorSpace(Rgb *color, Lab *item);
static void ToColor(Rgb *color, Lab *item);
};
typedef IConverter<Lab> LabConverter;
template <>
struct IConverter<Lch> {
static void ToColorSpace(Rgb *color, Lch *item);
static void ToColor(Rgb *color, Lch *item);
};
typedef IConverter<Lch> LchConverter;
template <>
struct IConverter<Luv> {
static void ToColorSpace(Rgb *color, Luv *item);
static void ToColor(Rgb *color, Luv *item);
};
typedef IConverter<Luv> LuvConverter;
template <>
struct IConverter<Yxy> {
static void ToColorSpace(Rgb *color, Yxy *item);
static void ToColor(Rgb *color, Yxy *item);
};
typedef IConverter<Yxy> YxyConverter;
template <>
struct IConverter<Cmy> {
static void ToColorSpace(Rgb *color, Cmy *item);
static void ToColor(Rgb *color, Cmy *item);
};
typedef IConverter<Cmy> CmyConverter;
template <>
struct IConverter<Cmyk> {
static void ToColorSpace(Rgb *color, Cmyk *item);
static void ToColor(Rgb *color, Cmyk *item);
};
typedef IConverter<Cmyk> CmykConverter;
template <>
struct IConverter<Hsv> {
static void ToColorSpace(Rgb *color, Hsv *item);
static void ToColor(Rgb *color, Hsv *item);
};
typedef IConverter<Hsv> HsvConverter;
template <>
struct IConverter<Hsb> {
static void ToColorSpace(Rgb *color, Hsb *item);
static void ToColor(Rgb *color, Hsb *item);
};
typedef IConverter<Hsb> HsbConverter;
template <>
struct IConverter<HunterLab> {
static void ToColorSpace(Rgb *color, HunterLab *item);
static void ToColor(Rgb *color, HunterLab *item);
};
typedef IConverter<HunterLab> HunterLabConverter;
}
#endif // RGB_CONVERTER_H