-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathColorConvert.h
More file actions
64 lines (46 loc) · 2.3 KB
/
ColorConvert.h
File metadata and controls
64 lines (46 loc) · 2.3 KB
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
/////////////////////////////////////////////////////////////////////////////////////
// color picker helper class by: //
// codeproject.com/Articles/2577/Xguiplus-A-set-of-Photoshop-s-like-color-pickers //
// //
/////////////////////////////////////////////////////////////////////////////////////
#ifndef UI_CONTROL_COLOR_CONVERT_H_
#define UI_CONTROL_COLOR_CONVERT_H_
#include <math.h>
#include <stdint.h>
namespace ui
{
typedef unsigned long COLORREF;
/** 颜色类型(RGB/HSV/HSL)转换类
*/
class ColorConvert
{
public:
// Convert from hsv to rgb value.
static int HSV2RGB(double hue, double sat, double value, double* red, double* green, double* blue);
// Convert from hsv to rgb value.
static int HSV2RGB(double hue, double sat, double value, uint8_t& red, uint8_t& green, uint8_t& blue);
// Convert from rgb to hsv value.
static int RGB2HSV(double red, double green, double blue, double* hue, double* sat, double* value);
// Convert from hsl to rgb value.
static int HSL2RGB(double hue, double sat, double lightness, double* red, double* green, double* blue);
// Convert from hsl to rgb value.
static int HSL2RGB(double hue, double sat, double lightness, uint8_t& red, uint8_t& green, uint8_t& blue);
// Convert from rgb to hsl value.
static int RGB2HSL(double red, double green, double blue, double* hue, double* sat, double* lightness);
// Get rgb value.
static void GetRGB(uint32_t* buffer, int samples, COLORREF start, COLORREF end);
// hsv from hue.
static void HSV_HUE(uint32_t* buffer, int samples, double sat, double val);
// hsv from sat.
static void HSV_SAT(uint32_t* buffer, int samples, double hue, double val);
// hsv value.
static void HSV_VAL(uint32_t* buffer, int samples, double hue, double sat);
// hsl from hue.
static void HSL_HUE(uint32_t* buffer, int samples, double sat, double lightness);
// hsl from sat.
static void HSL_SAT(uint32_t* buffer, int samples, double hue, double lightness);
// hsl lightness.
static void HSL_LIG(uint32_t* buffer, int samples, double hue, double sat);
};
} //namespace ui
#endif //UI_CONTROL_COLOR_CONVERT_H_