aboutsummaryrefslogtreecommitdiffstats
path: root/libglitter_split_uint64_raster.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-01-22 02:00:18 +0100
committerMattias Andrée <maandree@kth.se>2023-01-22 02:00:18 +0100
commitc326ecac54782734d5e27dc82b14d375238d1f79 (patch)
treec7af5105aa5edb3075bbc0487a8b6091d4652414 /libglitter_split_uint64_raster.c
parentm (diff)
downloadlibglitter-c326ecac54782734d5e27dc82b14d375238d1f79.tar.gz
libglitter-c326ecac54782734d5e27dc82b14d375238d1f79.tar.bz2
libglitter-c326ecac54782734d5e27dc82b14d375238d1f79.tar.xz
Add libglitter_split_uint{64,32}_raster
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libglitter_split_uint64_raster.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libglitter_split_uint64_raster.c b/libglitter_split_uint64_raster.c
new file mode 100644
index 0000000..a831ef7
--- /dev/null
+++ b/libglitter_split_uint64_raster.c
@@ -0,0 +1,31 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+void
+libglitter_split_uint64_raster(uint16_t *rasters[3], uint16_t **alphap, uint64_t *raster,
+ uint64_t red, uint64_t green, uint64_t blue)
+{
+ uint64_t alpha, map;
+ size_t position;
+ size_t channel;
+
+ alpha = ~(red | green | blue);
+ red /= 0xFF;
+ green /= 0xFF;
+ blue /= 0xFF;
+ alpha /= 0xFF;
+ red *= 0;
+ green *= 1;
+ blue *= 2;
+ alpha *= 3;
+ map = red | green | blue | alpha;
+
+ for (position = 0; position < 4; position++) {
+ channel = ((const unsigned char *)&map)[position * 2];
+ if (channel < 3)
+ rasters[channel] = &((uint16_t *)raster)[position];
+ else if (alphap)
+ *alphap = &((uint16_t *)raster)[position];
+ }
+}