diff --git a/components/display/core/gds_image.c b/components/display/core/gds_image.c index d76b564a..1be2089f 100644 --- a/components/display/core/gds_image.c +++ b/components/display/core/gds_image.c @@ -215,13 +215,21 @@ void GDS_DrawRGB16( struct GDS_Device* Device, uint16_t *Image, int x, int y, in } /**************************************************************************************** - * Simply draw a RGB 8 bits image (R:3,G:3,B:2) + * Simply draw a RGB 8 bits image (R:3,G:3,B:2) or plain grayscale * monochrome (0.2125 * color.r) + (0.7154 * color.g) + (0.0721 * color.b) * grayscale (0.3 * R) + (0.59 * G) + (0.11 * B) ) */ -void GDS_DrawRGB8( struct GDS_Device* Device, uint8_t *Image, int x, int y, int Width, int Height ) { +void GDS_DrawRGB8( struct GDS_Device* Device, uint8_t *Image, int x, int y, int Width, int Height, int RGB_Mode ) { if (Device->DrawRGB8) { - Device->DrawRGB8( Device, Image, x, y, Width, Height ); + Device->DrawRGB8( Device, Image, x, y, Width, Height, RGB_Mode ); + } else if (RGB_Mode == GDS_GRAYSCALE) { + // 8 bits pixels + int Scale = 8 - Device->Depth; + for (int r = 0; r < Height; r++) { + for (int c = 0; c < Width; c++) { + GDS_DrawPixel( Device, c + x, r + y, *Image++ >> Scale); + } + } } else if (Device->Depth < 3) { // 3 bits pixels to be placed int Scale = 3 - Device->Depth; diff --git a/components/display/core/gds_image.h b/components/display/core/gds_image.h index ec875fbd..b1f15c0c 100644 --- a/components/display/core/gds_image.h +++ b/components/display/core/gds_image.h @@ -7,7 +7,7 @@ struct GDS_Device; -enum { GDS_RGB565, GDS_RGB555, GDS_RGB444 }; +enum { GDS_RGB565, GDS_RGB555, GDS_RGB444, GDS_RGB332, GDS_GRAYSCALE }; // Fit options for GDS_DrawJPEG #define GDS_IMAGE_LEFT 0x00 @@ -24,4 +24,4 @@ uint16_t* GDS_DecodeJPEG(uint8_t *Source, int *Width, int *Height, float Scale) void GDS_GetJPEGSize(uint8_t *Source, int *Width, int *Height); bool GDS_DrawJPEG( struct GDS_Device* Device, uint8_t *Source, int x, int y, int Fit); void GDS_DrawRGB16( struct GDS_Device* Device, uint16_t *Image, int x, int y, int Width, int Height, int RGB_Mode ); -void GDS_DrawRGB8( struct GDS_Device* Device, uint8_t *Image, int x, int y, int Width, int Height ); \ No newline at end of file +void GDS_DrawRGB8( struct GDS_Device* Device, uint8_t *Image, int x, int y, int Width, int Height, int RGB_Mode ); \ No newline at end of file diff --git a/components/display/core/gds_private.h b/components/display/core/gds_private.h index efb829b4..42fa1a82 100644 --- a/components/display/core/gds_private.h +++ b/components/display/core/gds_private.h @@ -112,7 +112,7 @@ struct GDS_Device { void (*DrawBitmapCBR)(struct GDS_Device* Device, uint8_t *Data, int Width, int Height, int Color ); // may provide for optimization void (*DrawRGB16)( struct GDS_Device* Device, uint16_t *Image,int x, int y, int Width, int Height, int RGB_Mode ); - void (*DrawRGB8)( struct GDS_Device* Device, uint8_t *Image, int x, int y, int Width, int Height ); + void (*DrawRGB8)( struct GDS_Device* Device, uint8_t *Image, int x, int y, int Width, int Height, int RGB_Mode ); void (*ClearWindow)( struct GDS_Device* Device, int x1, int y1, int x2, int y2, int Color ); // interface-specific methods diff --git a/components/squeezelite/display.c b/components/squeezelite/display.c index 18cee3ca..2af283db 100644 --- a/components/squeezelite/display.c +++ b/components/squeezelite/display.c @@ -589,29 +589,15 @@ void draw_VU(struct GDS_Device * display, const uint8_t *data, int level, int x, data += (VU_WIDTH - width) / 2 * VU_HEIGHT; } - // this is RGB332, so pixel will be 3 bits deep - int depth = GDS_GetDepth(display); + // this is 8 bits grayscale + int scale = 8 - GDS_GetDepth(display); // use "fast" version as we are not beyond screen boundaries - if (depth < 3) { - int scale = 3 - depth; - for (int r = 0; r < width; r++) { - for (int c = 0; c < VU_HEIGHT; c++) { - int pixel = *data++; - pixel = ((((pixel & 0x3) * 11) << 1) + ((pixel >> 2) & 0x7) * 59 + (pixel >> 5) * 30 + 1) / 100; - GDS_DrawPixelFast(display, r + x, c + y, pixel >> scale); - } + for (int r = 0; r < width; r++) { + for (int c = 0; c < VU_HEIGHT; c++) { + GDS_DrawPixelFast(display, r + x, c + y, *data++ >> scale); } - } else { - int scale = depth - 3; - for (int r = 0; r < width; r++) { - for (int c = 0; c < VU_HEIGHT; c++) { - int pixel = *data++; - pixel = ((((pixel & 0x3) * 11) << 1) + ((pixel >> 2) & 0x7) * 59 + (pixel >> 5) * 30 + 1) / 100; - GDS_DrawPixelFast(display, r + x, c + y, pixel << scale); - } - } - } + } // need to manually set dirty flag as DrawPixel does not do it GDS_SetDirty(display); @@ -934,7 +920,7 @@ static void visu_update(void) { if (visu.bars[i].current > visu.bars[i].max) visu.bars[i].max = visu.bars[i].current; else if (visu.bars[i].max) visu.bars[i].max--; else if (!clear) continue; - + for (int j = 0; j <= visu.bars[i].current; j += 2) GDS_DrawLine(display, x1, y1 - j, x1 + visu.bar_width - 1, y1 - j, GDS_COLOR_WHITE);