2026-01-01 11:41 AM - edited 2026-01-01 11:42 AM
Hello,
I'm facing a issue with DMA2D to blend some images.
From the naming ARGB means that the order of the colors should be Alpha, Red, Green and Blue.
But if I have a PNG file which contains my image with Alpha, how I have to convert to a static image for my MCU to be able to work correctly with it with DMA2D?
Normally PNG is using RGBA format in big-endian. But if I'm converting this file to ARGB format and try to blend it over another image, it will work?
Also I'm confused with endianess, because I know that ARM normally is using little-endian.
Which is the best approach to load the image?
A struct like this:
typedef struct {
uint8_t A: 8;
uint8_t R: 8;
uint8_t G: 8;
uint8_t B: 8;
} ARGB_TypeDef;
typedef struct {
const uint16_t width;
const uint16_t height;
ARGB_TypeDef *data;
} FCU_Labels_TypeDef;Should work with DMA2D which requires uint32_t data for source and destination?
Thanks.
Solved! Go to Solution.
2026-01-01 1:14 PM
The DMA2D order that matters is the order within memory and is given by the reference manual:
If you were to interpret the same memory as a uint32_t, the order would be 0xBBGGRRAA since the STM32 is little-endian as all modern popular computing systems are.
Bit order within a struct is implementation defined. Yes, the bit field you have defined will work in most cases. But it's not guaranteed.
2026-01-01 1:14 PM
The DMA2D order that matters is the order within memory and is given by the reference manual:
If you were to interpret the same memory as a uint32_t, the order would be 0xBBGGRRAA since the STM32 is little-endian as all modern popular computing systems are.
Bit order within a struct is implementation defined. Yes, the bit field you have defined will work in most cases. But it's not guaranteed.
2026-01-01 1:24 PM
Thnaks @TDK ,
This is an good start for me. I will try to use a union instead of bit fields, something similat to this:
typedef union {
struct __attribute__((packed)) {
uint8_t B;
uint8_t G;
uint8_t R;
uint8_t A;
} components;
uint32_t value;
} ARGB8888_TypeDef;
I will play a little bit. I will build my own C program on my PC to convert correctly a PNg to ARGB format. Then I will load the static image to MCU, convert to RGB565 and I will try to send it to ST7789 SPI display.
I hope Iwill not face strage issues with ST7789 SPI endianess .