summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--locale/ID.po11
-rw-r--r--locale/circuitpython.pot11
-rw-r--r--locale/de_DE.po11
-rw-r--r--locale/en_US.po11
-rw-r--r--locale/es.po16
-rw-r--r--locale/fil.po16
-rw-r--r--locale/fr.po16
-rw-r--r--locale/it_IT.po16
-rw-r--r--locale/pt_BR.po16
-rw-r--r--shared-module/displayio/OnDiskBitmap.c63
-rw-r--r--shared-module/displayio/OnDiskBitmap.h5
11 files changed, 160 insertions, 32 deletions
diff --git a/locale/ID.po b/locale/ID.po
index 7e3a6c798..bfa219222 100644
--- a/locale/ID.po
+++ b/locale/ID.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-02-22 15:26-0800\n"
+"POT-Creation-Date: 2019-02-23 10:51-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -756,6 +756,11 @@ msgstr ""
msgid "Odd parity is not supported"
msgstr "Parity ganjil tidak didukung"
+#, c-format
+msgid ""
+"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"
+msgstr ""
+
msgid "Only 8 or 16 bit mono with "
msgstr "Hanya 8 atau 16 bit mono dengan "
@@ -770,7 +775,9 @@ msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
#, c-format
-msgid "Only true color (24 bpp or higher) BMP supported %x"
+msgid ""
+"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
+"BMP supported %d"
msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index 226a3a6fa..c36a10a4c 100644
--- a/locale/circuitpython.pot
+++ b/locale/circuitpython.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-02-22 15:26-0800\n"
+"POT-Creation-Date: 2019-02-23 10:51-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -730,6 +730,11 @@ msgstr ""
msgid "Odd parity is not supported"
msgstr ""
+#, c-format
+msgid ""
+"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"
+msgstr ""
+
msgid "Only 8 or 16 bit mono with "
msgstr ""
@@ -744,7 +749,9 @@ msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
#, c-format
-msgid "Only true color (24 bpp or higher) BMP supported %x"
+msgid ""
+"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
+"BMP supported %d"
msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
diff --git a/locale/de_DE.po b/locale/de_DE.po
index aff3c14f8..9da46fbea 100644
--- a/locale/de_DE.po
+++ b/locale/de_DE.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-02-22 15:26-0800\n"
+"POT-Creation-Date: 2019-02-23 10:51-0800\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@@ -745,6 +745,11 @@ msgstr ""
msgid "Odd parity is not supported"
msgstr "Eine ungerade Parität wird nicht unterstützt"
+#, c-format
+msgid ""
+"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"
+msgstr ""
+
msgid "Only 8 or 16 bit mono with "
msgstr "Nur 8 oder 16 bit mono mit "
@@ -759,7 +764,9 @@ msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
#, c-format
-msgid "Only true color (24 bpp or higher) BMP supported %x"
+msgid ""
+"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
+"BMP supported %d"
msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
diff --git a/locale/en_US.po b/locale/en_US.po
index c6bc8c5af..cb9d85a18 100644
--- a/locale/en_US.po
+++ b/locale/en_US.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-02-22 15:26-0800\n"
+"POT-Creation-Date: 2019-02-23 10:51-0800\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -730,6 +730,11 @@ msgstr ""
msgid "Odd parity is not supported"
msgstr ""
+#, c-format
+msgid ""
+"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"
+msgstr ""
+
msgid "Only 8 or 16 bit mono with "
msgstr ""
@@ -744,7 +749,9 @@ msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
#, c-format
-msgid "Only true color (24 bpp or higher) BMP supported %x"
+msgid ""
+"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
+"BMP supported %d"
msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
diff --git a/locale/es.po b/locale/es.po
index 46b9435e5..06a1f10f9 100644
--- a/locale/es.po
+++ b/locale/es.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-02-22 15:26-0800\n"
+"POT-Creation-Date: 2019-02-23 10:51-0800\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -770,6 +770,11 @@ msgstr ""
msgid "Odd parity is not supported"
msgstr "Paridad impar no soportada"
+#, c-format
+msgid ""
+"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"
+msgstr ""
+
msgid "Only 8 or 16 bit mono with "
msgstr "Solo mono de 8 o 16 bit con "
@@ -785,8 +790,10 @@ msgid "Only slices with step=1 (aka None) are supported"
msgstr "solo se admiten segmentos con step=1 (alias None)"
#, c-format
-msgid "Only true color (24 bpp or higher) BMP supported %x"
-msgstr "Solo color verdadero (24 bpp o superior) BMP admitido %x"
+msgid ""
+"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
+"BMP supported %d"
+msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
msgstr "Solo tx soportada en UART1 (GPIO2)"
@@ -2160,3 +2167,6 @@ msgstr "address fuera de límites"
msgid "zero step"
msgstr "paso cero"
+
+#~ msgid "Only true color (24 bpp or higher) BMP supported %x"
+#~ msgstr "Solo color verdadero (24 bpp o superior) BMP admitido %x"
diff --git a/locale/fil.po b/locale/fil.po
index 3dc70c626..0e79f2031 100644
--- a/locale/fil.po
+++ b/locale/fil.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-02-22 15:26-0800\n"
+"POT-Creation-Date: 2019-02-23 10:51-0800\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@@ -768,6 +768,11 @@ msgstr ""
msgid "Odd parity is not supported"
msgstr "Odd na parity ay hindi supportado"
+#, c-format
+msgid ""
+"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"
+msgstr ""
+
msgid "Only 8 or 16 bit mono with "
msgstr "Tanging 8 o 16 na bit mono na may "
@@ -783,8 +788,10 @@ msgid "Only slices with step=1 (aka None) are supported"
msgstr "ang mga slices lamang na may hakbang = 1 (aka None) ang sinusuportahan"
#, c-format
-msgid "Only true color (24 bpp or higher) BMP supported %x"
-msgstr "Dapat true color (24 bpp o mas mataas) BMP lamang ang supportado %x"
+msgid ""
+"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
+"BMP supported %d"
+msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
msgstr "Tanging suportado ang TX sa UART1 (GPIO2)."
@@ -2166,3 +2173,6 @@ msgstr "wala sa sakop ang address"
msgid "zero step"
msgstr "zero step"
+
+#~ msgid "Only true color (24 bpp or higher) BMP supported %x"
+#~ msgstr "Dapat true color (24 bpp o mas mataas) BMP lamang ang supportado %x"
diff --git a/locale/fr.po b/locale/fr.po
index 98911d64d..cb81f74ca 100644
--- a/locale/fr.po
+++ b/locale/fr.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-02-22 15:26-0800\n"
+"POT-Creation-Date: 2019-02-23 10:51-0800\n"
"PO-Revision-Date: 2018-12-23 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@@ -772,6 +772,11 @@ msgstr ""
msgid "Odd parity is not supported"
msgstr "parité impaire non supportée"
+#, c-format
+msgid ""
+"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"
+msgstr ""
+
msgid "Only 8 or 16 bit mono with "
msgstr "Uniquement 8 ou 16 bit mono avec "
@@ -787,8 +792,10 @@ msgid "Only slices with step=1 (aka None) are supported"
msgstr "seuls les slices avec 'step=1' (cad None) sont supportées"
#, c-format
-msgid "Only true color (24 bpp or higher) BMP supported %x"
-msgstr "Seul les BMP 24bits ou plus sont supportés %x"
+msgid ""
+"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
+"BMP supported %d"
+msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
msgstr "Seul le tx est supporté sur l'UART1 (GPIO2)."
@@ -2190,3 +2197,6 @@ msgstr "adresse hors limites"
msgid "zero step"
msgstr "'step' nul"
+
+#~ msgid "Only true color (24 bpp or higher) BMP supported %x"
+#~ msgstr "Seul les BMP 24bits ou plus sont supportés %x"
diff --git a/locale/it_IT.po b/locale/it_IT.po
index 55c6c065e..83664a146 100644
--- a/locale/it_IT.po
+++ b/locale/it_IT.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-02-22 15:26-0800\n"
+"POT-Creation-Date: 2019-02-23 10:51-0800\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@@ -767,6 +767,11 @@ msgstr ""
msgid "Odd parity is not supported"
msgstr "operazione I2C non supportata"
+#, c-format
+msgid ""
+"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"
+msgstr ""
+
msgid "Only 8 or 16 bit mono with "
msgstr ""
@@ -782,8 +787,10 @@ msgid "Only slices with step=1 (aka None) are supported"
msgstr "solo slice con step=1 (aka None) sono supportate"
#, c-format
-msgid "Only true color (24 bpp or higher) BMP supported %x"
-msgstr "Solo BMP true color (24 bpp o superiore) sono supportati %x"
+msgid ""
+"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
+"BMP supported %d"
+msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
msgstr "Solo tx supportato su UART1 (GPIO2)."
@@ -2162,3 +2169,6 @@ msgstr "indirizzo fuori limite"
msgid "zero step"
msgstr "zero step"
+
+#~ msgid "Only true color (24 bpp or higher) BMP supported %x"
+#~ msgstr "Solo BMP true color (24 bpp o superiore) sono supportati %x"
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index 6b08dcef0..70e7bde4a 100644
--- a/locale/pt_BR.po
+++ b/locale/pt_BR.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2019-02-22 15:26-0800\n"
+"POT-Creation-Date: 2019-02-23 10:51-0800\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -756,6 +756,11 @@ msgstr ""
msgid "Odd parity is not supported"
msgstr "I2C operação não suportada"
+#, c-format
+msgid ""
+"Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"
+msgstr ""
+
msgid "Only 8 or 16 bit mono with "
msgstr ""
@@ -770,8 +775,10 @@ msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
#, c-format
-msgid "Only true color (24 bpp or higher) BMP supported %x"
-msgstr "Apenas cores verdadeiras (24 bpp ou maior) BMP suportadas"
+msgid ""
+"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
+"BMP supported %d"
+msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
msgstr "Apenas TX suportado no UART1 (GPIO2)."
@@ -2110,3 +2117,6 @@ msgstr ""
msgid "zero step"
msgstr "passo zero"
+
+#~ msgid "Only true color (24 bpp or higher) BMP supported %x"
+#~ msgstr "Apenas cores verdadeiras (24 bpp ou maior) BMP suportadas"
diff --git a/shared-module/displayio/OnDiskBitmap.c b/shared-module/displayio/OnDiskBitmap.c
index aa2ca3e10..bc3064632 100644
--- a/shared-module/displayio/OnDiskBitmap.c
+++ b/shared-module/displayio/OnDiskBitmap.c
@@ -38,13 +38,13 @@ static uint32_t read_word(uint16_t* bmp_header, uint16_t index) {
void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, pyb_file_obj_t* file) {
// Load the wave
self->file = file;
- uint16_t bmp_header[24];
+ uint16_t bmp_header[69];
f_rewind(&self->file->fp);
UINT bytes_read;
- if (f_read(&self->file->fp, bmp_header, 48, &bytes_read) != FR_OK) {
+ if (f_read(&self->file->fp, bmp_header, 138, &bytes_read) != FR_OK) {
mp_raise_OSError(MP_EIO);
}
- if (bytes_read != 48 ||
+ if (bytes_read != 138 ||
memcmp(bmp_header, "BM", 2) != 0) {
mp_raise_ValueError(translate("Invalid BMP file"));
}
@@ -53,15 +53,35 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
self->data_offset = read_word(bmp_header, 5);
uint32_t header_size = read_word(bmp_header, 7);
+ uint16_t bits_per_pixel = bmp_header[14];
uint32_t compression = read_word(bmp_header, 15);
- if (!(header_size == 12 || header_size == 40 || header_size == 108 || header_size == 124) ||
+ uint32_t number_of_colors = read_word(bmp_header, 23);
+ self->bitfield_compressed = (compression == 3);
+
+ self->grayscale = ((bits_per_pixel == 8) && (number_of_colors == 256));
+ if (bits_per_pixel == 16){
+ if (((header_size == 124) || (header_size == 56)) && (self->bitfield_compressed)) {
+ self->r_bitmask = read_word(bmp_header, 27);
+ self->g_bitmask = read_word(bmp_header, 29);
+ self->b_bitmask = read_word(bmp_header, 31);
+
+ if (!((self->r_bitmask == 0xf800) && (self->g_bitmask == 0x07e0) && (self->b_bitmask == 0x001f))){
+ mp_raise_ValueError_varg(translate("Only 16bpp RGB 565 supported for bitfield compressed BMPs; R:%x G:%x B:%x"),
+ self->r_bitmask, self->g_bitmask, self->b_bitmask);
+ }
+ } else if (header_size == 40){ // no bitmasks means 5:5:5
+ self->r_bitmask = 0x7c00;
+ self->g_bitmask = 0x3e0;
+ self->b_bitmask = 0x1f;
+ }
+
+ } else if (!(header_size == 12 || header_size == 40 || header_size == 108 || header_size == 124) ||
!(compression == 0)) {
mp_raise_ValueError_varg(translate("Only Windows format, uncompressed BMP supported %d"), header_size);
}
- // TODO(tannewt): Support bitfield compressed colors since RGB565 can be produced by the GIMP.
- uint16_t bits_per_pixel = bmp_header[14];
- if (bits_per_pixel < 24) {
- mp_raise_ValueError_varg(translate("Only true color (24 bpp or higher) BMP supported %x"), bits_per_pixel);
+
+ if (bits_per_pixel < 16 && !(self->grayscale)) {
+ mp_raise_ValueError_varg(translate("Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale BMP supported %d"), bits_per_pixel);
}
self->bytes_per_pixel = bits_per_pixel / 8;
self->width = read_word(bmp_header, 9);
@@ -87,7 +107,32 @@ uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *s
uint32_t pixel = 0;
uint32_t result = f_read(&self->file->fp, &pixel, self->bytes_per_pixel, &bytes_read);
if (result == FR_OK) {
- return pixel;
+ uint32_t tmp = 0;
+ uint8_t red;
+ uint8_t green;
+ uint8_t blue;
+ if (self->grayscale){
+ red = pixel;
+ green = pixel;
+ blue = pixel;
+ tmp = (red << 16 | green << 8 | blue);
+ return tmp;
+ } else if (self->bytes_per_pixel == 2) {
+ if (self->bitfield_compressed){
+ red =((pixel & self->r_bitmask) >>11);
+ green = ((pixel & self->g_bitmask) >>5);
+ blue = ((pixel & self->b_bitmask) >> 0);
+ } else {
+ red =((pixel & self->r_bitmask) >>10);
+ green = ((pixel & self->g_bitmask) >>4);
+ blue = ((pixel & self->b_bitmask) >> 0);
+ }
+ tmp = (red << 19 | green << 10 | blue << 3);
+ return tmp;
+ }else {
+ return pixel;
+ }
+
}
return 0;
}
diff --git a/shared-module/displayio/OnDiskBitmap.h b/shared-module/displayio/OnDiskBitmap.h
index 31d6c9550..2102863d6 100644
--- a/shared-module/displayio/OnDiskBitmap.h
+++ b/shared-module/displayio/OnDiskBitmap.h
@@ -40,6 +40,11 @@ typedef struct {
uint16_t height;
uint16_t data_offset;
uint16_t stride;
+ uint32_t r_bitmask;
+ uint32_t g_bitmask;
+ uint32_t b_bitmask;
+ bool bitfield_compressed;
+ bool grayscale;
pyb_file_obj_t* file;
uint8_t bytes_per_pixel;
} displayio_ondiskbitmap_t;