summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Siepert <bsiepert@gmail.com>2019-02-27 21:02:48 -0800
committerBryan Siepert <bsiepert@gmail.com>2019-02-28 23:08:12 -0800
commit398c7060f8a51bb83b0f5e0c2a1611d684603d2b (patch)
tree0c3b13f040917c2a448dfe2ceb29e979d2df847d
parent2c9fbb5d40c457e87a4c0db3906960484f3668c0 (diff)
added monochrome, 8bpp indexed, and 32bpp ARGB BMPs
-rw-r--r--locale/ID.po18
-rw-r--r--locale/circuitpython.pot18
-rw-r--r--locale/de_DE.po18
-rw-r--r--locale/en_US.po18
-rw-r--r--locale/es.po20
-rw-r--r--locale/fil.po20
-rw-r--r--locale/fr.po20
-rw-r--r--locale/it_IT.po20
-rw-r--r--locale/pt_BR.po18
-rw-r--r--shared-module/displayio/OnDiskBitmap.c104
-rw-r--r--shared-module/displayio/OnDiskBitmap.h4
11 files changed, 140 insertions, 138 deletions
diff --git a/locale/ID.po b/locale/ID.po
index bfa219222..c0b1dafdb 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-23 10:51-0800\n"
+"POT-Creation-Date: 2019-02-28 23:07-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,11 +756,6 @@ 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 "
@@ -771,13 +766,11 @@ msgstr ""
msgid "Only bit maps of 8 bit color or less are supported"
msgstr ""
-msgid "Only slices with step=1 (aka None) are supported"
+#, c-format
+msgid "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"
msgstr ""
-#, c-format
-msgid ""
-"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
-"BMP supported %d"
+msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
@@ -984,6 +977,9 @@ msgstr "Tidak dapat menemukan GCLK yang kosong"
msgid "Unable to init parser"
msgstr ""
+msgid "Unable to read color palette data"
+msgstr ""
+
msgid "Unable to remount filesystem"
msgstr "Tidak dapat memasang filesystem kembali"
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index 318adc768..ea6b26c3f 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-23 19:57-0800\n"
+"POT-Creation-Date: 2019-02-28 23:07-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,11 +730,6 @@ 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 ""
@@ -745,13 +740,11 @@ msgstr ""
msgid "Only bit maps of 8 bit color or less are supported"
msgstr ""
-msgid "Only slices with step=1 (aka None) are supported"
+#, c-format
+msgid "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"
msgstr ""
-#, c-format
-msgid ""
-"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
-"BMP supported %d"
+msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
@@ -951,6 +944,9 @@ msgstr ""
msgid "Unable to init parser"
msgstr ""
+msgid "Unable to read color palette data"
+msgstr ""
+
msgid "Unable to remount filesystem"
msgstr ""
diff --git a/locale/de_DE.po b/locale/de_DE.po
index d9354f01f..ff9cafc76 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-23 19:57-0800\n"
+"POT-Creation-Date: 2019-02-28 23:07-0800\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@@ -748,11 +748,6 @@ 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 "
@@ -764,13 +759,11 @@ msgid "Only bit maps of 8 bit color or less are supported"
msgstr ""
"Es werden nur Bitmaps mit einer Farbtiefe von 8 Bit oder weniger unterstützt"
-msgid "Only slices with step=1 (aka None) are supported"
+#, c-format
+msgid "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"
msgstr ""
-#, c-format
-msgid ""
-"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
-"BMP supported %d"
+msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
@@ -984,6 +977,9 @@ msgstr "Konnte keinen freien GCLK finden"
msgid "Unable to init parser"
msgstr "Parser konnte nicht gestartet werden"
+msgid "Unable to read color palette data"
+msgstr ""
+
msgid "Unable to remount filesystem"
msgstr "Dateisystem konnte nicht wieder eingebunden werden."
diff --git a/locale/en_US.po b/locale/en_US.po
index cb9d85a18..45596fb62 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-23 10:51-0800\n"
+"POT-Creation-Date: 2019-02-28 23:07-0800\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -730,11 +730,6 @@ 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 ""
@@ -745,13 +740,11 @@ msgstr ""
msgid "Only bit maps of 8 bit color or less are supported"
msgstr ""
-msgid "Only slices with step=1 (aka None) are supported"
+#, c-format
+msgid "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"
msgstr ""
-#, c-format
-msgid ""
-"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
-"BMP supported %d"
+msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
@@ -951,6 +944,9 @@ msgstr ""
msgid "Unable to init parser"
msgstr ""
+msgid "Unable to read color palette data"
+msgstr ""
+
msgid "Unable to remount filesystem"
msgstr ""
diff --git a/locale/es.po b/locale/es.po
index 06a1f10f9..996d58df6 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-23 10:51-0800\n"
+"POT-Creation-Date: 2019-02-28 23:07-0800\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -770,11 +770,6 @@ 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,16 +780,14 @@ msgstr "Solo formato Windows, BMP sin comprimir soportado %d"
msgid "Only bit maps of 8 bit color or less are supported"
msgstr "Solo se admiten bit maps de color de 8 bits o menos"
+#, c-format
+msgid "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"
+msgstr ""
+
#, fuzzy
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), 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)"
@@ -1003,6 +996,9 @@ msgstr "No se pudo encontrar un GCLK libre"
msgid "Unable to init parser"
msgstr "Incapaz de inicializar el parser"
+msgid "Unable to read color palette data"
+msgstr ""
+
msgid "Unable to remount filesystem"
msgstr "Incapaz de montar de nuevo el sistema de archivos"
diff --git a/locale/fil.po b/locale/fil.po
index 0e79f2031..af5046d7c 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-23 10:51-0800\n"
+"POT-Creation-Date: 2019-02-28 23:07-0800\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@@ -768,11 +768,6 @@ 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,16 +778,14 @@ msgstr "Tanging Windows format, uncompressed BMP lamang ang supportado %d"
msgid "Only bit maps of 8 bit color or less are supported"
msgstr "Tanging bit maps na may 8 bit color o mas mababa ang supportado"
+#, c-format
+msgid "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"
+msgstr ""
+
#, fuzzy
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), 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)."
@@ -1005,6 +998,9 @@ msgstr "Hindi mahanap ang libreng GCLK"
msgid "Unable to init parser"
msgstr "Hindi ma-init ang parser"
+msgid "Unable to read color palette data"
+msgstr ""
+
msgid "Unable to remount filesystem"
msgstr "Hindi ma-remount ang filesystem"
diff --git a/locale/fr.po b/locale/fr.po
index cb81f74ca..3fde90bde 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-23 10:51-0800\n"
+"POT-Creation-Date: 2019-02-28 23:07-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,11 +772,6 @@ 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,16 +782,14 @@ msgstr "Seul les BMP non-compressé au format Windows sont supportés %d"
msgid "Only bit maps of 8 bit color or less are supported"
msgstr "Seules les bitmaps de 8bits par couleur ou moins sont supportées"
+#, c-format
+msgid "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"
+msgstr ""
+
#, fuzzy
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), 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)."
@@ -1016,6 +1009,9 @@ msgstr "Impossible de trouver un GCLK libre"
msgid "Unable to init parser"
msgstr "Impossible d'initialiser le parser"
+msgid "Unable to read color palette data"
+msgstr ""
+
msgid "Unable to remount filesystem"
msgstr "Impossible de remonter le système de fichiers"
diff --git a/locale/it_IT.po b/locale/it_IT.po
index 83664a146..ea1a42b11 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-23 10:51-0800\n"
+"POT-Creation-Date: 2019-02-28 23:07-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,11 +767,6 @@ 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,16 +777,14 @@ msgstr "Formato solo di Windows, BMP non compresso supportato %d"
msgid "Only bit maps of 8 bit color or less are supported"
msgstr "Sono supportate solo bitmap con colori a 8 bit o meno"
+#, c-format
+msgid "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"
+msgstr ""
+
#, fuzzy
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), 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)."
@@ -1003,6 +996,9 @@ msgstr "Impossibile trovare un GCLK libero"
msgid "Unable to init parser"
msgstr "Inizilizzazione del parser non possibile"
+msgid "Unable to read color palette data"
+msgstr ""
+
msgid "Unable to remount filesystem"
msgstr "Imposssibile rimontare il filesystem"
diff --git a/locale/pt_BR.po b/locale/pt_BR.po
index 70e7bde4a..8477e1478 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-23 10:51-0800\n"
+"POT-Creation-Date: 2019-02-28 23:07-0800\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@@ -756,11 +756,6 @@ 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 ""
@@ -771,13 +766,11 @@ msgstr "Apenas formato Windows, BMP descomprimido suportado"
msgid "Only bit maps of 8 bit color or less are supported"
msgstr "Apenas bit maps de cores de 8 bit ou menos são suportados"
-msgid "Only slices with step=1 (aka None) are supported"
+#, c-format
+msgid "Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"
msgstr ""
-#, c-format
-msgid ""
-"Only true color (24 bpp or higher), 16bpp 565 and 555, and 8bpp grayscale "
-"BMP supported %d"
+msgid "Only slices with step=1 (aka None) are supported"
msgstr ""
msgid "Only tx supported on UART1 (GPIO2)."
@@ -979,6 +972,9 @@ msgstr "Não é possível encontrar GCLK livre"
msgid "Unable to init parser"
msgstr ""
+msgid "Unable to read color palette data"
+msgstr ""
+
msgid "Unable to remount filesystem"
msgstr "Não é possível remontar o sistema de arquivos"
diff --git a/shared-module/displayio/OnDiskBitmap.c b/shared-module/displayio/OnDiskBitmap.c
index bc3064632..76d8fb2d1 100644
--- a/shared-module/displayio/OnDiskBitmap.c
+++ b/shared-module/displayio/OnDiskBitmap.c
@@ -56,42 +56,65 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self,
uint16_t bits_per_pixel = bmp_header[14];
uint32_t compression = read_word(bmp_header, 15);
uint32_t number_of_colors = read_word(bmp_header, 23);
+
+ bool indexed = ((bits_per_pixel <= 8) && (number_of_colors != 0));
self->bitfield_compressed = (compression == 3);
-
- self->grayscale = ((bits_per_pixel == 8) && (number_of_colors == 256));
+ self->bits_per_pixel = bits_per_pixel;
+ self->width = read_word(bmp_header, 9);
+ self->height = read_word(bmp_header, 11);
+
if (bits_per_pixel == 16){
- if (((header_size == 124) || (header_size == 56)) && (self->bitfield_compressed)) {
+ if (((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
+ } else { // no compression or short header means 5:5:5
self->r_bitmask = 0x7c00;
self->g_bitmask = 0x3e0;
self->b_bitmask = 0x1f;
}
+ } else if ((indexed) && (self->bits_per_pixel != 1)) {
+ uint16_t palette_size = number_of_colors * sizeof(uint32_t);
+ uint16_t palette_offset = 0xe + header_size;
+
+ self->palette_data = m_malloc(palette_size, false);
+
+ f_rewind(&self->file->fp);
+ f_lseek(&self->file->fp, palette_offset);
+
+ UINT palette_bytes_read;
+ if (f_read(&self->file->fp, self->palette_data, palette_size, &palette_bytes_read) != FR_OK) {
+ mp_raise_OSError(MP_EIO);
+ }
+ if (palette_bytes_read != palette_size) {
+ mp_raise_ValueError(translate("Unable to read color palette data"));
+ }
+
- } else if (!(header_size == 12 || header_size == 40 || header_size == 108 || header_size == 124) ||
- !(compression == 0)) {
+ } else if (!(header_size == 12 || header_size == 40 || header_size == 108 || header_size == 124)) {
mp_raise_ValueError_varg(translate("Only Windows format, uncompressed BMP supported %d"), header_size);
}
- 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);
+ if ((bits_per_pixel == 4 ) || (( bits_per_pixel == 8) && (number_of_colors == 0))) {
+ mp_raise_ValueError_varg(translate("Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d"), bits_per_pixel);
}
- self->bytes_per_pixel = bits_per_pixel / 8;
- self->width = read_word(bmp_header, 9);
- self->height = read_word(bmp_header, 11);
- uint32_t byte_width = self->width * self->bytes_per_pixel;
- self->stride = byte_width;
- // Rows are word aligned.
- if (self->stride % 4 != 0) {
- self->stride += 4 - self->stride % 4;
+
+ if (self->bits_per_pixel >=8){
+ self->stride = (self->width * (bits_per_pixel / 8));
+ // Rows are word aligned.
+ if (self->stride % 4 != 0) {
+ self->stride += 4 - self->stride % 4;
+ }
+
+ } else {
+ uint32_t bit_stride = self->width;
+ if (bit_stride % 32 != 0) {
+ bit_stride += 32 - bit_stride % 32;
+ }
+ self->stride = (bit_stride / 8);
}
+
}
@@ -100,39 +123,54 @@ uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *s
if (x < 0 || x >= self->width || y < 0 || y >= self->height) {
return 0;
}
- uint32_t location = self->data_offset + (self->height - y) * self->stride + x * self->bytes_per_pixel;
+ uint32_t location;
+ uint8_t bytes_per_pixel = (self->bits_per_pixel / 8) ? (self->bits_per_pixel /8) : 1;
+ if (self->bits_per_pixel >= 8){
+ location = self->data_offset + (self->height - y) * self->stride + x * bytes_per_pixel;
+ } else {
+ location = self->data_offset + (self->height - y) * self->stride + x / 8;
+ }
// We don't cache here because the underlying FS caches sectors.
f_lseek(&self->file->fp, location);
UINT bytes_read;
- uint32_t pixel = 0;
- uint32_t result = f_read(&self->file->fp, &pixel, self->bytes_per_pixel, &bytes_read);
+ uint32_t pixel = 0; // this name is stale
+ uint32_t result = f_read(&self->file->fp, &pixel, bytes_per_pixel, &bytes_read);
if (result == FR_OK) {
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);
+ if (self->bits_per_pixel == 1){
+ uint8_t bit_offset = x%8;
+ tmp = ( pixel & (0x80 >> (bit_offset))) >> (7 - bit_offset);
+ if (tmp == 1) {
+ return 0x00FFFFFF;
+ } else {
+ return 0x00000000;
+ }
+ } else if (bytes_per_pixel == 1){
+ blue = ((self->palette_data[pixel] & 0xFF) >> 0);
+ red = ((self->palette_data[pixel] & 0xFF0000) >> 16);
+ green = ((self->palette_data[pixel] & 0xFF00) >> 8);
+ tmp = (red << 16 | green << 8 | blue );
return tmp;
- } else if (self->bytes_per_pixel == 2) {
- if (self->bitfield_compressed){
+ } else if (bytes_per_pixel == 2) {
+ if (self->g_bitmask == 0x07e0){ // 565
red =((pixel & self->r_bitmask) >>11);
green = ((pixel & self->g_bitmask) >>5);
blue = ((pixel & self->b_bitmask) >> 0);
- } else {
+ } else { // 555
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 {
+ }else if ((bytes_per_pixel == 4) && (self->bitfield_compressed)){
+ return pixel & 0x00FFFFFF;
+ } else {
return pixel;
}
-
}
return 0;
}
diff --git a/shared-module/displayio/OnDiskBitmap.h b/shared-module/displayio/OnDiskBitmap.h
index 2102863d6..28426f11b 100644
--- a/shared-module/displayio/OnDiskBitmap.h
+++ b/shared-module/displayio/OnDiskBitmap.h
@@ -44,9 +44,9 @@ typedef struct {
uint32_t g_bitmask;
uint32_t b_bitmask;
bool bitfield_compressed;
- bool grayscale;
pyb_file_obj_t* file;
- uint8_t bytes_per_pixel;
+ uint8_t bits_per_pixel;
+ uint32_t* palette_data;
} displayio_ondiskbitmap_t;
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_ONDISKBITMAP_H