PatchworkOS
966e257
A non-POSIX operating system.
Theme:
Default
Round
Robot
Loading...
Searching...
No Matches
pixel.h
Go to the documentation of this file.
1
#ifndef PATCHWORK_PIXEL_H
2
#define PATCHWORK_PIXEL_H 1
3
4
#include <
stdint.h
>
5
6
#if defined(__cplusplus)
7
extern
"C"
8
{
9
#endif
10
11
typedef
uint32_t
pixel_t
;
12
13
#define PIXEL_ALPHA(pixel) (((pixel) >> 24) & 0xFF)
14
#define PIXEL_RED(pixel) (((pixel) >> 16) & 0xFF)
15
#define PIXEL_GREEN(pixel) (((pixel) >> 8) & 0xFF)
16
#define PIXEL_BLUE(pixel) (((pixel) >> 0) & 0xFF)
17
18
#define PIXEL_ARGB(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | ((b) << 0))
19
20
#define PIXEL_BLEND(dest, src) \
21
({ \
22
uint8_t aAlpha = PIXEL_ALPHA(*src); \
23
uint8_t bAlpha = PIXEL_ALPHA(*dest); \
24
uint8_t alpha = aAlpha + ((bAlpha * (0xFF - aAlpha)) / 0xFF); \
25
if (alpha != 0) \
26
{ \
27
*dest = PIXEL_ARGB(alpha, \
28
(PIXEL_RED(*src) * aAlpha + PIXEL_RED(*dest) * bAlpha * (0xFF - aAlpha) / 0xFF) / alpha, \
29
(PIXEL_GREEN(*src) * aAlpha + PIXEL_GREEN(*dest) * bAlpha * (0xFF - aAlpha) / 0xFF) / alpha, \
30
(PIXEL_BLUE(*src) * aAlpha + PIXEL_BLUE(*dest) * bAlpha * (0xFF - aAlpha) / 0xFF) / alpha); \
31
} \
32
else \
33
{ \
34
*dest = 0; \
35
} \
36
})
37
38
#if defined(__cplusplus)
39
}
40
#endif
41
42
#endif
pixel_t
uint32_t pixel_t
Definition
pixel.h:11
stdint.h
uint32_t
__UINT32_TYPE__ uint32_t
Definition
stdint.h:15
include
libpatchwork
pixel.h
Generated on Mon Dec 15 2025 21:55:53 for PatchworkOS by
1.9.8