2025-09-01 6:44 PM
Framebuffer is RGB565,Can I make a dynamic bitmap of ARGB8888?
I made one by cacheable container and display the dynamic bitmap by a texturemapper but the image came out is not correct,something did appear on screen,but size and color not right. but if I change bitmap type to rgb565,the image show correctly,but with black background and no alpha ,not what I wanted. There is enough cache,I confirm the dynamic bitmap is created successfully on both type.I tried to display the dynamic bitmap by a Image widget,but the result is the same.
In this forum,I can see a solution,to register a LCD32bpp class and set it as Auxiliary LCD in the hal.
But I didn't found any thread on this subject.
How to use off screen rendering of a textarea in a... - STMicroelectronics Community
Can I get any help from any @st guys?
Solved! Go to Solution.
2025-12-10 5:09 AM
Hello @amb.
Sorry for the late reply!
I have attached a simple example that shows how you can use both 16bpp and 32bpp dynamic bitmaps at the same time.
Best regards,
Johan
2025-09-02 7:13 AM
Hello @amb.
You are correct that you need to create an LCD32bpp object and pass it to the auxiliary LCD.
When TouchGFX renders a dynamic bitmap, it uses the auxiliary LCD. The auxiliary LCD is natively in the same format as the framebuffer. This means that the dynamic bitmaps are rendered to RAM in this format, which in this case means all dynamic bitmaps are in RGB565 format.
The format of the auxiliary LCD can be changed as follows:
#include <platform/driver/lcd/LCD32bpp.hpp>
static LCD32bpp lcd32;
HAL::getInstance()->setAuxiliaryLCD(&lcd32);You can do it anywhere in the GUI code.
The downside of changing the format of the auxiliary LCD is that all dynamic bitmaps in the application will now be in 32bpp. However, you can change back and forth between formats at runtime. You can give it a nullpointer to reset to the default format.
Best regards,
Johan
2025-09-02 9:38 PM
Hello @JohanAstrup
In my application,I have a few rgb565 dynamic bitmaps as the background,and I need only one ARGB dynamic bitmap as addon infomation layer.
As you said ,if I create rgb565 dynamic bitmap,I need to call HAL::getInstance()->setAuxiliaryLCD(null) and if I create ARGB565 dynamic bitmap,I need to call HAL::getInstance()->setAuxiliaryLCD(&lcd32),Is that correct?
How do I refresh content in container?Just call cacheableContainer.updateCache() ? Or I have to call setAuxiliaryLCD() before refresh?
I am still confused about this ,can you give some more information?
2025-09-04 4:46 AM
Good question!
I have checked, and the main LCD will actually be used as fallback if the color format of the dynamic bitmap does not match the color format of the auxiliary LCD. There, set up the auxiliary LCD to 32bpp, and then you should be able to render both 16bpp and 32bpp dynamic bitmaps, assuming your color depth is still 16bpp.
Please try it out and let me know if you experience any issues with the scenario described above.
Best regards,
Johan
2025-09-05 9:47 PM
I have tried your solution,but didn't work.
Here is my code structure:
static LCD32bpp lcd32;
Screen1View::Screen1View()
{ tickcount=0;
dynamicBitmapRGB565 = Bitmap::dynamicBitmapCreate(768, 768, Bitmap::RGB565);
HAL::getInstance()->setAuxiliaryLCD(&lcd32);
dynamicBitmapsFace = Bitmap::dynamicBitmapCreate(200, 150, Bitmap::ARGB8888);
hdgFace.setCacheBitmap(dynamicBitmapsFace);
hdgFace.enableCachedMode(true);
hdgFace.updateCache();
rotator.setBitmap(dynamicBitmapsFace);
rotator.setWidth(200);
rotator.setHeight(150);
rotator.setBitmapPosition(0.0f, 0.0f);
rotator.setVisible(true);
rotator.invalidate();
HAL::getInstance()->setAuxiliaryLCD(0);
}It should look like this:
but instead it looks:
hdgFace is a cacheable Container size 200*150. these two lines,one circle and one box with border are drawn to hdgFace.the box with border looks normal,but the other object is only half size on X axis.
2025-12-10 5:09 AM
Hello @amb.
Sorry for the late reply!
I have attached a simple example that shows how you can use both 16bpp and 32bpp dynamic bitmaps at the same time.
Best regards,
Johan
2026-02-14 10:04 PM
Hello @JohanAstrup
Thanks for your kind reply.
I tried your code,It works but only partly.
Half of the display is good,the other half have random pixels on screen.
2026-02-15 4:34 AM
Hello @JohanAstrup
I finally make these random pixels disappear,by using memset() before render.
But then I found another problem.
this is what I want:
but after download I got this:
if you put a image into the container(using dynamic bitmap ARGB),then it shows correctly,but if you draw a line or a circle,it shows wrongly, and the circle does not draw at all.
Line color changed.Line position and length changed.
Based on these problems,I think there may be some bug in touchgfx core code.
What can I do to make it right?
Hope for your reply.
2026-02-17 1:59 AM
Hi amb.
Great that you were able to make it work!
The reason Canvas widgets do not work is that TouchGFX Designer does not know about your 32bpp LCD class. Therefore, only the default RGB565 painter is generated, and you must manually set a new painter when using ARGB8888.
I have updated and attached the previously shared example with a Line widget.
In Screen1ViewBase.hpp, you can see that TouchGFX generates the following code:
touchgfx::Line line2;
touchgfx::PainterRGB565 line2Painter;As you can see, this is an RGB565 painter.
To overwrite it, include the following header in your view:
#include <touchgfx/widgets/canvas/PainterARGB8888.hpp>
Then, in e.g. setupScreen, write the following code:
// Modify painter color format for line2
PainterARGB8888 line2PainterARGB;
line2PainterARGB.setColor(touchgfx::Color::getColorFromRGB(0, 255, 30));
line2.setPainter(line2PainterARGB);The reason not all painters are always generated is to limit code size. However, this results in this less optimal solution when Canvas widgets are used in a dynamic bitmap with a color depth different from the framebuffer.
Best regards,
Johan
2026-02-17 4:47 AM
Hello @JohanAstrup
I think you are right,this is the key to the problem.But after I add
#include <touchgfx/widgets/canvas/PainterARGB8888.hpp> and that code above, cubeide compiles with error:
(.text._ZNK8touchgfx15PainterARGB88885paintEPhssssh+0x16): undefined reference to `touchgfx::paint::argb8888::lineFromColor(unsigned long*, short, unsigned long, unsigned char)'
I never find out the reason.Maybe because I don't know C++ very much,I only know C.
Best Regards