diff options
| author | Bryan Siepert <bsiepert@gmail.com> | 2019-03-01 07:16:14 -0800 |
|---|---|---|
| committer | Bryan Siepert <bsiepert@gmail.com> | 2019-03-01 07:17:50 -0800 |
| commit | 014595bff593e51012483515adf92e21c7126f5d (patch) | |
| tree | 9399c0cfeadff2aa2d88a304dadd71ac4eb8d849 /shared-module/displayio/OnDiskBitmap.c | |
| parent | 398c7060f8a51bb83b0f5e0c2a1611d684603d2b (diff) | |
fixed whitespace, clarified variable name, and updated error messages
Diffstat (limited to 'shared-module/displayio/OnDiskBitmap.c')
| -rw-r--r-- | shared-module/displayio/OnDiskBitmap.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/shared-module/displayio/OnDiskBitmap.c b/shared-module/displayio/OnDiskBitmap.c index 76d8fb2d1..92735e53c 100644 --- a/shared-module/displayio/OnDiskBitmap.c +++ b/shared-module/displayio/OnDiskBitmap.c @@ -93,11 +93,11 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, } 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); + mp_raise_ValueError_varg(translate("Only Windows format, uncompressed BMP supported: given header size is %d"), header_size); } 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); + mp_raise_ValueError_varg(translate("Only monochrome, indexed 8bpp, and 16bpp or greater BMPs supported: %d bpp given"), bits_per_pixel); } if (self->bits_per_pixel >=8){ @@ -133,8 +133,8 @@ uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *s // We don't cache here because the underlying FS caches sectors. f_lseek(&self->file->fp, location); UINT bytes_read; - uint32_t pixel = 0; // this name is stale - uint32_t result = f_read(&self->file->fp, &pixel, bytes_per_pixel, &bytes_read); + uint32_t pixel_data = 0; // this name is stale + uint32_t result = f_read(&self->file->fp, &pixel_data, bytes_per_pixel, &bytes_read); if (result == FR_OK) { uint32_t tmp = 0; uint8_t red; @@ -142,34 +142,34 @@ uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *s uint8_t blue; if (self->bits_per_pixel == 1){ uint8_t bit_offset = x%8; - tmp = ( pixel & (0x80 >> (bit_offset))) >> (7 - bit_offset); + tmp = ( pixel_data & (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); + blue = ((self->palette_data[pixel_data] & 0xFF) >> 0); + red = ((self->palette_data[pixel_data] & 0xFF0000) >> 16); + green = ((self->palette_data[pixel_data] & 0xFF00) >> 8); tmp = (red << 16 | green << 8 | blue ); return tmp; } 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); + if (self->g_bitmask == 0x07e0) { // 565 + red =((pixel_data & self->r_bitmask) >>11); + green = ((pixel_data & self->g_bitmask) >>5); + blue = ((pixel_data & self->b_bitmask) >> 0); } else { // 555 - red =((pixel & self->r_bitmask) >>10); - green = ((pixel & self->g_bitmask) >>4); - blue = ((pixel & self->b_bitmask) >> 0); + red =((pixel_data & self->r_bitmask) >>10); + green = ((pixel_data & self->g_bitmask) >>4); + blue = ((pixel_data & self->b_bitmask) >> 0); } tmp = (red << 19 | green << 10 | blue << 3); return tmp; - }else if ((bytes_per_pixel == 4) && (self->bitfield_compressed)){ - return pixel & 0x00FFFFFF; + } else if ((bytes_per_pixel == 4) && (self->bitfield_compressed)) { + return pixel_data & 0x00FFFFFF; } else { - return pixel; + return pixel_data; } } return 0; |
