ColorConverter: Add "BGR" color modes.
The BGR565_SWAPPED mode is needed for OV2640 cameras.
This commit is contained in:
parent
826e25989c
commit
d83a21b984
@ -147,11 +147,6 @@ msgstr ""
|
||||
msgid "%q must of type %q"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/keypad/KeyMatrix.c shared-bindings/keypad/Keys.c
|
||||
#: shared-bindings/keypad/ShiftRegisterKeys.c
|
||||
msgid "%q must store bytes"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||
#: shared-bindings/canio/Match.c
|
||||
msgid "%q out of range"
|
||||
|
@ -70,6 +70,10 @@ MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565, DISPLAY
|
||||
MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565_SWAPPED, DISPLAYIO_COLORSPACE_RGB565_SWAPPED);
|
||||
MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAYIO_COLORSPACE_RGB555);
|
||||
MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED);
|
||||
MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565, DISPLAYIO_COLORSPACE_BGR565);
|
||||
MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR565_SWAPPED);
|
||||
MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555, DISPLAYIO_COLORSPACE_BGR555);
|
||||
MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED);
|
||||
|
||||
//| class Colorspace:
|
||||
//| """The colorspace for a `ColorConverter` to operate in"""
|
||||
@ -95,6 +99,10 @@ MAKE_ENUM_MAP(displayio_colorspace) {
|
||||
MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565_SWAPPED),
|
||||
MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555),
|
||||
MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555_SWAPPED),
|
||||
MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565),
|
||||
MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565_SWAPPED),
|
||||
MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555),
|
||||
MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555_SWAPPED),
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(displayio_colorspace_locals_dict, displayio_colorspace_locals_table);
|
||||
|
||||
|
@ -46,6 +46,10 @@ typedef enum {
|
||||
DISPLAYIO_COLORSPACE_RGB555,
|
||||
DISPLAYIO_COLORSPACE_RGB565_SWAPPED,
|
||||
DISPLAYIO_COLORSPACE_RGB555_SWAPPED,
|
||||
DISPLAYIO_COLORSPACE_BGR565,
|
||||
DISPLAYIO_COLORSPACE_BGR555,
|
||||
DISPLAYIO_COLORSPACE_BGR565_SWAPPED,
|
||||
DISPLAYIO_COLORSPACE_BGR555_SWAPPED,
|
||||
} displayio_colorspace_t;
|
||||
|
||||
typedef bool (*display_bus_bus_reset)(mp_obj_t bus);
|
||||
|
@ -176,6 +176,28 @@ void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _d
|
||||
}
|
||||
break;
|
||||
|
||||
case DISPLAYIO_COLORSPACE_BGR565_SWAPPED:
|
||||
pixel = __builtin_bswap16(pixel);
|
||||
MP_FALLTHROUGH;
|
||||
case DISPLAYIO_COLORSPACE_BGR565: {
|
||||
uint32_t b8 = (pixel >> 11) << 3;
|
||||
uint32_t g8 = ((pixel >> 5) << 2) & 0xff;
|
||||
uint32_t r8 = (pixel << 3) & 0xff;
|
||||
pixel = (r8 << 16) | (g8 << 8) | b8;
|
||||
}
|
||||
break;
|
||||
|
||||
case DISPLAYIO_COLORSPACE_BGR555_SWAPPED:
|
||||
pixel = __builtin_bswap16(pixel);
|
||||
MP_FALLTHROUGH;
|
||||
case DISPLAYIO_COLORSPACE_BGR555: {
|
||||
uint32_t b8 = (pixel >> 10) << 3;
|
||||
uint32_t g8 = ((pixel >> 5) << 3) & 0xff;
|
||||
uint32_t r8 = (pixel << 3) & 0xff;
|
||||
pixel = (r8 << 16) | (g8 << 8) | b8;
|
||||
}
|
||||
break;
|
||||
|
||||
case DISPLAYIO_COLORSPACE_RGB888:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user