cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Bitmap Background Transparency Implementation

TesterSAM
Associate II

Hi, 

I would like to capture a TextArea's content and use it with TextureMapper for scaling animation and a blurry filter effect on the bitmap data.

However, there is noise for the TextArea background in HW, but the simulator result is perfect. 

The reasons for using TextureMapper with Bitmap Data:

  • the TextArea content will be updated
  • the screen background will be updated
  • filter effect function will be applied to the TextArea's content
  • Able to implement the scaling & fade animation

 

How to create a Bitmap Data with Font/image's content without a noisy background?

----------------------------------------------------------------------------

STM32U5G9-DK Result (noise for the Background):

TesterSAM_2-1762132382532.png

Simulator Result (expected):

TesterSAM_0-1762132235476.png

----------------------------------------------------------------------------

The Dynamic Bitmap creation (Reference to advanceAnimationContainer.cpp in Text Animation Demo):

TestFont1Bitmap = Bitmap::dynamicBitmapCreate(Container.getWidth(), Container.getHeight(), Bitmap::ARGB8888);
	touchgfx_printf("TestFont1Bitmap %d \n", TestFont1Bitmap);
	if (TestFont1Bitmap != BITMAP_INVALID)
	{
		FontTM.setBitmap(TestFont1Bitmap);
		FontTM.setPosition(50, 50, Container.getWidth(), Container.getHeight());
		FontTM.setBitmapPosition(0, 0);

		Container.setCacheBitmap(TestFont1Bitmap);
		Container.enableCachedMode(true);
		Container.updateCache();

		Container.setAlpha(0);
		FontTM.setupAnimation(AnimationTextureMapper::SCALE, 0.8f, 62, 0, EasingEquations::linearEaseInOut);
		FontTM.startAnimation();
	}

 ---------------------------------------------------------------------------------------------------------

Please feel free to download the project for your testing.

 

 

2 REPLIES 2
PeterVang
ST Employee

Hello,

The noise you see in the dynamic bitmaps comes from the memory not being initialized. You can e.g. fix this by inserting the following between line 4 and 5 in your code snippet above:

memset((void*)TestFont1Bitmap.getData(), 0, TestFont1Bitmap.getWidth() * TestFont1Bitmap.getHeight() * 4);

Be aware that you might see another glitch (with the text characters being "scrambled") when reprogramming a running board. This can be solved by power-cycling the board or by inserting the following code to the last user code section of MX_DCACHE2_Init function in main.c:

  /* USER CODE BEGIN DCACHE2_Init 2 */
  // Ensure that GPU2D texture cache does not hold any out-dated data from previous application
  __HAL_RCC_GPU2D_CLK_ENABLE();
  HAL_DCACHE_Invalidate(&hdcache2);
  /* USER CODE END DCACHE2_Init 2 */

Note: This code is already included when using the project template for STM32U5G9J-DK2 from TouchGFX Designer 4.26.0 and forward.

Best regards,

Peter

TesterSAM
Associate II

@PeterVang Thank you so much. The Noise background issue is fixed.

 

I got another issue that I tried to apply a Blur function to the Bitmap data, the simulator could review the result, but the Hardware failed. 

Any idea about this issue?

Any Demo/ Example that applied a filter effect to the Bitmap Data?

Any plan to add a built-in filter feature in TouchGFX in the feature?

---------------------------------------------------------------------------------------------------

STM32U5G9-DK result:

Radius = 1TesterSAM_2-1762165663374.png

Missing TextureMapper "FontTM"

Radius = 2Triggered HardFault

 

Simulator result:

Radius = 1TesterSAM_1-1762165543453.png

Normal

Radius = 2TesterSAM_3-1762165752200.png

Normal