summaryrefslogtreecommitdiff
path: root/kms++util/inc/kms++util/color.h
blob: fa05fbcc1982d03a4a7fcf85c8556cd85f038832 (plain)
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
#pragma once

#include <cstdint>

namespace kms
{
struct YUV;

enum class YUVType {
	BT601_Lim = 0,
	BT601_Full,
	BT709_Lim,
	BT709_Full,
	MAX,
};

struct RGB
{
	RGB();
	RGB(uint8_t r, uint8_t g, uint8_t b);
	RGB(uint8_t a, uint8_t r, uint8_t g, uint8_t b);
	RGB(uint32_t argb);

	uint32_t rgb888() const;
	uint32_t bgr888() const;
	uint32_t argb8888() const;
	uint32_t abgr8888() const;
	uint32_t rgba8888() const;
	uint32_t bgra8888() const;

	// XXX these functions leave the lowest 2 bits zero
	uint32_t argb2101010() const;
	uint32_t abgr2101010() const;
	uint32_t rgba1010102() const;
	uint32_t bgra1010102() const;

	uint8_t rgb332() const;
	uint16_t rgb565() const;
	uint16_t bgr565() const;
	uint16_t argb4444() const;
	uint16_t argb1555() const;
	YUV yuv(YUVType type = YUVType::BT601_Lim) const;

	uint8_t b;
	uint8_t g;
	uint8_t r;
	uint8_t a;
};

struct YUV
{
	YUV();
	YUV(uint8_t y, uint8_t u, uint8_t v);
	YUV(const RGB& rgb, YUVType type = YUVType::BT601_Lim);

	uint8_t v;
	uint8_t u;
	uint8_t y;
	uint8_t a;
};
}