diff --git a/project/Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_lcd.c b/project/Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_lcd.c index 3d2987f..8277ff3 100644 --- a/project/Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_lcd.c +++ b/project/Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_lcd.c @@ -1021,7 +1021,7 @@ void BSP_LCD_DrawPixel(uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code) */ void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp) { - uint32_t index = 0, width = 0, height = 0, bit_pixel = 0; + uint32_t index = 0, width = 0, height = 0, bit_pixel = 0, row_size = 0; uint32_t address; uint32_t input_color_mode = 0; @@ -1039,6 +1039,9 @@ void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp) /* Set the address */ address = hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4)); + + /* Calculate the row size in byte */ + row_size = ((bit_pixel*width + 31)/32) * 4; /* Get the layer pixel format */ if ((bit_pixel/8) == 4) @@ -1053,20 +1056,20 @@ void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp) { input_color_mode = CM_RGB888; } - + /* Bypass the bitmap header */ - pbmp += (index + (width * (height - 1) * (bit_pixel/8))); - + pbmp += (index + (row_size * (height - 1))); + /* Convert picture to ARGB8888 pixel format */ for(index=0; index < height; index++) { /* Pixel format conversion */ LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)address, width, input_color_mode); - + /* Increment the source and destination buffers */ - address+= (BSP_LCD_GetXSize()*4); - pbmp -= width*(bit_pixel/8); - } + address += (BSP_LCD_GetXSize()*4); + pbmp -= row_size; + } } /**