diff options
Diffstat (limited to '')
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | libglitter.h | 33 | ||||
-rw-r--r-- | libglitter_split_uint32_raster.c | 5 | ||||
-rw-r--r-- | libglitter_split_uint64_raster.c | 31 |
4 files changed, 72 insertions, 0 deletions
@@ -29,6 +29,8 @@ OBJ =\ libglitter_free_render_context.o\ libglitter_get_colour_space_conversion_matrix_double.o\ libglitter_get_colour_space_conversion_matrix_float.o\ + libglitter_split_uint32_raster.o\ + libglitter_split_uint64_raster.o\ libglitter_update_render_context.o HDR =\ @@ -47,6 +49,7 @@ libglitter_compose_uint32.o: libglitter_compose_uint64.c libglitter_compose_doub libglitter_compose_uint64.o: libglitter_compose_double.c libglitter_compose_uint8.o: libglitter_compose_uint64.c libglitter_compose_double.c libglitter_desaturate_float.o: libglitter_desaturate_double.c +libglitter_split_uint32_raster.o: libglitter_split_uint64_raster.c .c.o: $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) diff --git a/libglitter.h b/libglitter.h index 826ca16..dfb9e30 100644 --- a/libglitter.h +++ b/libglitter.h @@ -158,6 +158,39 @@ void libglitter_compose_uint8(uint8_t **, const uint8_t *restrict, size_t, size_ /** + * Splits a `uint64_t` raster into one `uint16_t` raster per channel + * + * @param rasters Output array for the rasters, they will be in the + * order (0) red, (1) green, (2) blue + * @param alphap Output parameter for the alpha mask rasters, or `NULL` + * @param raster The raster that is being split + * @param red The value `0xFFFF` shifted such that value + * expresses pure red (closest primary colour) + * @param green The value `0xFFFF` shifted such that value + * expresses pure green (closest primary colour) + * @param blue The value `0xFFFF` shifted such that value + * expresses pure blue (closest primary colour) + */ +void libglitter_split_uint64_raster(uint16_t *[3], uint16_t **, uint64_t *, uint64_t, uint64_t, uint64_t); + +/** + * Splits a `uint32_t` raster into one `uint8_t` raster per channel + * + * @param rasters Output array for the rasters, they will be in the + * order (0) red, (1) green, (2) blue + * @param alphap Output parameter for the alpha mask rasters, or `NULL` + * @param raster The raster that is being split + * @param red The value `0xFF` shifted such that value + * expresses pure red (closest primary colour) + * @param green The value `0xFF` shifted such that value + * expresses pure green (closest primary colour) + * @param blue The value `0xFF` shifted such that value + * expresses pure blue (closest primary colour) + */ +void libglitter_split_uint32_raster(uint8_t *[3], uint8_t **, uint32_t *, uint32_t, uint32_t, uint32_t); + + +/** * Transform rasters from fully using subpixel rendering to * balance between subpixel rendering and greyscale antialiasing * diff --git a/libglitter_split_uint32_raster.c b/libglitter_split_uint32_raster.c new file mode 100644 index 0000000..a8b44f5 --- /dev/null +++ b/libglitter_split_uint32_raster.c @@ -0,0 +1,5 @@ +#include "common.h" +#define libglitter_split_uint64_raster libglitter_split_uint32_raster +#define uint64_t uint32_t +#define uint16_t uint8_t +#include "libglitter_split_uint64_raster.c" 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]; + } +} |