blob: 564d7c579a51d8c7a6b3728ac78aebfaed0e254d (
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
|
#include <lib/bool.h>
#include <lib/color.h>
#include <stdio.h>
// Color Equal to Background
// Background: zeros in RGB, alpha can be whatever
bool_t color_zero(const ImageData_t *color1, size_t channels) {
for (size_t idx = 0; idx < channels; idx++) {
if (idx == 3) {
break;
}
if (color1[idx] != 0) {
return FALSE;
}
}
return TRUE;
}
// Color Equality
// Determine if two colors are identical
bool_t color_equal(const ImageData_t *color1, const ImageData_t *color2,
size_t channels) {
for (size_t idx = 0; idx < channels; idx++) {
if (color1[idx] != color2[idx]) {
return FALSE;
}
}
return TRUE;
}
// Print out the `channels` length color vector
void print_color(ImageData_t *color, size_t channels) {
for (size_t index = 0; index < channels; index++) {
printf("%hhu ", color[index]);
}
printf("\n");
}
|