Fix BSP_LCD_DrawBitmap function to account for padding in bitmap images
This commit is contained in:
@@ -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)
|
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 address;
|
||||||
uint32_t input_color_mode = 0;
|
uint32_t input_color_mode = 0;
|
||||||
|
|
||||||
@@ -1040,6 +1040,9 @@ void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp)
|
|||||||
/* Set the address */
|
/* Set the address */
|
||||||
address = hLtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + (((BSP_LCD_GetXSize()*Ypos) + Xpos)*(4));
|
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 */
|
/* Get the layer pixel format */
|
||||||
if ((bit_pixel/8) == 4)
|
if ((bit_pixel/8) == 4)
|
||||||
{
|
{
|
||||||
@@ -1055,7 +1058,7 @@ void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Bypass the bitmap header */
|
/* Bypass the bitmap header */
|
||||||
pbmp += (index + (width * (height - 1) * (bit_pixel/8)));
|
pbmp += (index + (row_size * (height - 1)));
|
||||||
|
|
||||||
/* Convert picture to ARGB8888 pixel format */
|
/* Convert picture to ARGB8888 pixel format */
|
||||||
for(index=0; index < height; index++)
|
for(index=0; index < height; index++)
|
||||||
@@ -1064,8 +1067,8 @@ void BSP_LCD_DrawBitmap(uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp)
|
|||||||
LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)address, width, input_color_mode);
|
LL_ConvertLineToARGB8888((uint32_t *)pbmp, (uint32_t *)address, width, input_color_mode);
|
||||||
|
|
||||||
/* Increment the source and destination buffers */
|
/* Increment the source and destination buffers */
|
||||||
address+= (BSP_LCD_GetXSize()*4);
|
address += (BSP_LCD_GetXSize()*4);
|
||||||
pbmp -= width*(bit_pixel/8);
|
pbmp -= row_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user