aboutsummaryrefslogtreecommitdiffstats
path: root/libglitter_split_uint64_raster.c
diff options
context:
space:
mode:
Diffstat (limited to 'libglitter_split_uint64_raster.c')
-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];
+ }
+}