Skip to main content
Jack3
Senior
March 6, 2026
Solved

GPU2D and RGB565: Can the GPU2D use dithering in gradients?

  • March 6, 2026
  • 4 replies
  • 563 views

Hello, I'm using an STM32U5G7VJTx MCU with a 480x320 display, connected to the FMC in 16-bit mode, and everything works fine using the GPU2D. I'm not using an existing GUI framework.

The pixel format used by the display is RGB565 (16bpp), so for gradients, I want to use dithering to soften the banding. I found this definition in the 'nema_graphics.h' file:

#define NEMA_DITHER 0x80U /**< Nema Dithering */

However, it seems undocumented. How do I make use of it?

Kind regerds, Jack.

Best answer by JBJOE.1

Hi @Jack3 

You’re right, there is a dither option in nema_graphics.h. I haven’t actively used it in a project yet, but from what I can see it’s a feature you enable on the destination (framebuffer), so it performs dithering at runtime when blitting. You need to specify both the color format and the dither option, like this:

img_obj_t fb;
fb.w = RESX;
fb.h = RESY;
fb.format = NEMA_RGBA8888 | NEMA_DITHER;
fb.stride = RESX*4;
nema_bind_dst_tex(fb_base_phys, fb.w, fb.h, fb.format, fb.stride);

 Regards, 
Jakob

4 replies

mƎALLEm
Technical Moderator
March 6, 2026

Hello,


@Jack3 wrote:

I'm not using an existing GUI framework.


If you are not using a specific GUI framework why posting in STM32 MCUs TouchGFX and GUI forum board?

Where you find that 'nema_graphics.h' file? a ST package? 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
Jack3
Jack3Author
Senior
March 26, 2026

That is abundantly clear: it says "and GUI", and this concerns exactly a GUI, albeit my own.
BTW, GUI stands for "Graphical User Interface".
Thank you for your concern. I hope this helps.

mƎALLEm
Technical Moderator
March 26, 2026

I know what GUI means and this forum board is only focusing on TouchGFX solution. Therefore this post will be moved to the correct forum board.

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
JBJOE.1
JBJOE.1Best answer
ST Employee
March 11, 2026

Hi @Jack3 

You’re right, there is a dither option in nema_graphics.h. I haven’t actively used it in a project yet, but from what I can see it’s a feature you enable on the destination (framebuffer), so it performs dithering at runtime when blitting. You need to specify both the color format and the dither option, like this:

img_obj_t fb;
fb.w = RESX;
fb.h = RESY;
fb.format = NEMA_RGBA8888 | NEMA_DITHER;
fb.stride = RESX*4;
nema_bind_dst_tex(fb_base_phys, fb.w, fb.h, fb.format, fb.stride);

 Regards, 
Jakob

Jakob BJOERNSenior Software Engineer | STM32 Graphics
Jack3
Jack3Author
Senior
March 24, 2026

Hi Jakob, thank you very much!
That works like a charm!
It is much desired on 16-bit famebuffers like below:

img_obj_t fb;
fbo.w = ILI9488_SIZE_X;
fbo.h = ILI9488_SIZE_Y;
fbo.stride = fbo.w * ILI9488_BYTES_PER_PIXEL; /* ILI9488_BYTES_PER_PIXEL = 2 */
fbo.format = NEMA_BGR565 | NEMA_DITHER;
nema_bind_dst_tex(fb_base_phys, fb.w, fb.h, fb.format, fb.stride);

You are a super-hero!
Regards,
Jack.

mƎALLEm
Technical Moderator
March 26, 2026

After checking with @Osman SOYKURT , it seems that Nema knowledge (Think Silicon was the owner of that solution) was transferred to ST (something that I was not aware of as moderator).

Therefore, any other Nema related questions need to be posted in TouchGFX forum board to be treated by TouchGFX team as they can handle it.

PS: meanwhile we (as admins) keep the same position: questions about solutions not provided by ST while using STM32 MCUs need to be posted in "Others: STM32 MCUs related" forum board such as LVGL, QT GUI etc..

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
Jack3
Jack3Author
Senior
March 27, 2026

Note that the GPU2D and NemaGFX libraries aren't covered by the reference manuals at all, as you figured.

So I had the assumption that the TouchGFX team has the most knowledge about GPU2D and the NemaGFX libraries, much more than "Others: STM32 MCUs related", or am I wrong about that?

JBJOE.1
ST Employee
April 8, 2026

Hi @Jack3 

You are right, the TouchGFX team has a lot of knowledge on the GPU2D. I will most likely see all posts on related to NeoChorm, especially if they are posted in "STM32 MCUs TouchGFX and GUI". 
So, keep the Topics flowing, I will try to help as best as I can. 

Regards,

Jakob BJOERNSenior Software Engineer | STM32 Graphics