From 05a81a066e50a4ab1786f21c80189b4025065bc1 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 23 Apr 2021 09:57:24 -0500 Subject: [PATCH] displayio: Improve docs about Colorspaces --- shared-bindings/displayio/ColorConverter.c | 11 +++++------ shared-bindings/displayio/__init__.c | 12 ++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index ce1af77839..a5b154b341 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -40,15 +40,14 @@ //| class ColorConverter: //| """Converts one color format to another.""" //| -//| def __init__(self, *, dither: bool = False) -> None: -//| """Create a ColorConverter object to convert color formats. Only supports RGB888 to RGB565 -//| currently. +//| def __init__(self, *, colorspace: Colorspace=Colorspace.RGB888, dither: bool = False) -> None: +//| """Create a ColorConverter object to convert color formats. +//| +//| :param Colorspace colorspace: The source colorspace, one of the Colorspace constants //| :param bool dither: Adds random noise to dither the output image""" //| ... //| -// TODO(tannewt): Add support for other color formats. -//| STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_dither, ARG_input_colorspace }; @@ -68,7 +67,7 @@ STATIC mp_obj_t displayio_colorconverter_make_new(const mp_obj_type_t *type, siz } //| def convert(self, color: int) -> int: -//| """Converts the given RGB888 color to RGB565""" +//| """Converts the given color to RGB565 according to the Colorspace""" //| ... //| STATIC mp_obj_t displayio_colorconverter_obj_convert(mp_obj_t self_in, mp_obj_t color_obj) { diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index eaa085031f..17fe8b057b 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -72,22 +72,22 @@ MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAY MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED); //| class Colorspace: -//| """The colorspace for a ColorConverter to operate in""" +//| """The colorspace for a `ColorConverter` to operate in""" //| //| RGB888: object -//| """The standard 24-bit colorspace""" +//| """The standard 24-bit colorspace. Bits 0-7 are blue, 8-15 are green, and 16-24 are red. (0xRRGGBB)""" //| //| RGB565: object -//| """The standard 16-bit colorspace""" +//| """The standard 16-bit colorspace. Bits 0-4 are blue, bits 5-10 are green, and 11-15 are red (0bRRRRRGGGGGGBBBBB)""" //| //| RGB565_SWAPPED: object -//| """The standard 16-bit colorspace, with low and high bytes swapped""" +//| """The swapped 16-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB565""" //| //| RGB555: object -//| """The standard 15-bit colorspace""" +//| """The standard 15-bit colorspace. Bits 0-4 are blue, bits 5-9 are green, and 11-14 are red. The top bit is ignored. (0bxRRRRRGGGGGBBBBB)""" //| //| RGB555_SWAPPED: object -//| """The standard 15-bit colorspace, with low and high bytes swapped""" +//| """The swapped 15-bit colorspace. First, the high and low 8 bits of the number are swapped, then they are interpreted as for RGB555""" //| MAKE_ENUM_MAP(displayio_colorspace) { MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB888),