Question
Drawing a bitmap using 2D DMA on STMF32F4
Posted on June 08, 2018 at 19:30
I'm trying to draw a bitmap using 2D DMA, so I have the address of the destination which is the front buffer, and then I read a line from the bitmap, blit it using the 2D DMA.. I get scanlines, and garbage image. Not sure where is the problem
/**
* @brief Displays a bitmap picture loaded in the internal Flash (32 bpp). * @param X: the bmp x position in the LCD * @param Y: the bmp Y position in the LCD * @param pBmp: Bmp picture address in the internal Flash */ void BSP_LCD_DrawBitmap(uint16_t layer,uint32_t X, uint32_t Y, const uint8_t *pBmp) { uint32_t index = 0, width = 0, height = 0, bitpixel = 0; uint32_t address; uint32_t inputcolormode = 0; /* Get bitmap data address offset */ index = 0;/* Read bitmap width */
width = 240;/* Read bitmap height */
height = 320;/* Read bit/pixel */
bitpixel = 2; if ( ActiveLayer == 0 ) { address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress ; } else { address = LtdcHandler.LayerCfg[ActiveLayer].FBStartAdress + 240*320*2; } inputcolormode = CM_RGB565; /* Convert picture to RGB565 pixel format */ for(index=0; index < height; index++) { /* Pixel format conversion */ ConvertLineToRGB565((uint16_t *)pBmp, (uint16_t *)address, width, inputcolormode);/* Increment the source and destination SCREENs */
address+= ((BSP_LCD_GetXSize() - width + width)*2); pBmp += width*(bitpixel/2); }
