2024-04-24 02:27 AM
Hi everyone,
Im using the stm32f429disc1 board with a lcd and Im trying to get the dma2d to blend images. But right now the alpha blending is giving me odd results. Here is a image:
On the left is what is currently being drawn, and the right is the test image. When the image has all 255 alpha it draws fine, as shown by the brick pattern below, but any time I try with some alpha it does not draw correctly. Here is my code:
void LCD_Draw_Wall(uint32_t data, uint16_t x, uint16_t y, uint32_t width, uint32_t height) {
uint32_t destination = LCD_FRAME_BUFFER1 + (x + y * LCD_PIXEL_WIDTH_X) * 4; // LCD_FRAME_BUFFER_BOTTOM + (x + y * LCD_PIXEL_WIDTH_X) * 3;
DMA2D_HandleTypeDef hdma2d;
hdma2d.Instance = DMA2D;
hdma2d.Init.Mode = DMA2D_M2M;
hdma2d.Init.ColorMode = DMA2D_OUTPUT_ARGB8888;
hdma2d.Init.OutputOffset = LCD_PIXEL_WIDTH_X - width;
hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888;
hdma2d.LayerCfg[1].InputOffset = 0;
//background
hdma2d.LayerCfg[0].AlphaMode = DMA2D_NO_MODIF_ALPHA;
hdma2d.LayerCfg[0].InputColorMode = DMA2D_INPUT_ARGB8888;
hdma2d.LayerCfg[0].InputOffset = LCD_PIXEL_WIDTH_X - width;
HAL_DMA2D_Init(&hdma2d);
HAL_DMA2D_ConfigLayer(&hdma2d, 1);
HAL_DMA2D_ConfigLayer(&hdma2d, 0);
HAL_DMA2D_BlendingStart(&hdma2d, data, destination, destination, width, height);
HAL_DMA2D_PollForTransfer(&hdma2d, 10);
}
//layer config
pLayerCfg.Alpha = 255;
pLayerCfg.Alpha0 = 255;
pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;
pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;
pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0;
//Draw call:
LCD_Draw_Wall((uintptr_t)img_data_right, 96,16 , 43, 38);
Here is the data that is being passed in :
const unsigned char img_data_right[] LOCATION_EXTFLASH_ATTRIBUTE = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xee, 0xee, 0xee, 0xff, 0xcb, 0xcb, 0xcb, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3,}; //(chopped off most of it due to character limit on stm fourms)
If anyone has some ideas that is much appreciated.