BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: How to make a selected color transparent?  (Read 8099 times)

Kalle

  • Newbie
  • *
  • Posts: 3
    • View Profile
How to make a selected color transparent?
« on: June 02, 2021, 12:24:33 PM »

I have created icons in PNG format with the background in black and the foreground in white color. I’m trying to make the black color transparent without success.

The funny thing is when I’m using the SetFont2 command to display my custom font, the black color gets transparent.

I have no problem to change the icon color.

Code: [Select]
App_WrCoCmd_Buffer(phost, COLOR_RGB(255, 255, 64));
Gpu_CoCmd_SetBitmap(phost, MEM_ICON_GEAR, COMPRESSED_RGBA_ASTC_4x4_KHR, 32, 32);
App_WrCoCmd_Buffer(phost, BEGIN(BITMAPS));
App_WrCoCmd_Buffer(phost, VERTEX2F(_x * 16, _y * 16));

I have read a lots of documentation and tried many different ways but cannot get it to work.

If I save the PNG file with a transparent background, it works, but it gets much better quality when I have the black background as the icon is only 32x32px.
Logged

pauljiao

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
Re: How to make a selected color transparent?
« Reply #1 on: June 03, 2021, 11:02:34 AM »

try to convert the PNG to ASTC format with EAB . ASTC preserves the alpha channel.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 734
    • View Profile
Re: How to make a selected color transparent?
« Reply #2 on: June 03, 2021, 12:39:52 PM »

Hello,

Unfortunately it is not really practical to modify an image with a flat (black) background to make this appear transparent.

One option maybe to convert the image to ARGB1555 via EBA to include the transparent background, this should result in a better quality image when the transparent background is used. You can store this conversion in flash and load it into RAM_G when required by your application.

Best Regards,
BRT Community
Logged

Kalle

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to make a selected color transparent?
« Reply #3 on: June 03, 2021, 08:48:22 PM »

I have already tried to convert them to both ASTC and ARGB1555, saved them in flash and load it into RAM_G. The transparent background is preserved in both cases, but the transition between background and foreground is not smooth.

As I wrote in my first post, the transition between background and foreground will be much smoother if I save it with a black background, but to get the black background transparent I have to run the command:
Code: [Select]
EVE_cmd_setfont2_burst(12,MEM_FONT,0);
If you look at the png image that is generated when you generate custom fonts in EBA, it also has a black background, so there must be a relationship between setfont2 command and that the black background becomes transparent?

Attached is the EBA converted image.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 734
    • View Profile
Re: How to make a selected color transparent?
« Reply #4 on: June 04, 2021, 01:43:00 PM »

Hello,

Thank you for the clarification, I have contacted the development team to see if they can advise on this use case.

Best Regards,
BRT Community
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 734
    • View Profile
Re: How to make a selected color transparent?
« Reply #5 on: June 10, 2021, 12:00:19 PM »

Hello,

The developers have asked if it is possible to provide the original PNG image files before any EAB conversion has taken place:
1.   PNG with transparent background.
2.   PNG with black background.

Also can you provide the display list utilised with the black background PNG and the setfont2 command?

Best Regards,
BRT Community
Logged

Kalle

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to make a selected color transparent?
« Reply #6 on: June 18, 2021, 12:43:33 PM »

Attached is the PNG files.

I have stored the PNG files with black background and my custom font in the flash and then utilised:

Setup method
Code: [Select]
Gpu_CoCmd_FlashHelper_Init(phost);
Gpu_CoCmd_FlashHelper_SwitchFullMode(phost);
Gpu_CoCmd_FlashRead(phost, MEM_FONT_DIGITAL_MEDIUM, 45056, 192);
Gpu_CoCmd_FlashRead(phost, MEM_ICON_GEAR, 45248, 2048);


Render image
Code: [Select]
Gpu_CoCmd_Dlstart(_phost);
App_WrCoCmd_Buffer(_phost, SCREEN_BG_PRIMARY_COLOR);
App_WrCoCmd_Buffer(_phost, CLEAR(1, 1, 1));

Gpu_CoCmd_SetFont2(_phost, 2, MEM_FONT_DIGITAL_MEDIUM, 1);
Gpu_CoCmd_SetBitmap(_phost, MEM_ICON_GEAR, COMPRESSED_RGBA_ASTC_4x4_KHR, 32, 32);
App_WrCoCmd_Buffer(_phost, BEGIN(BITMAPS));
App_WrCoCmd_Buffer(_phost, VERTEX2F(200 * 16, 135 * 16));

App_WrCoCmd_Buffer(_phost, DISPLAY());
App_Flush_Co_Buffer(_phost);
Gpu_CoCmd_Swap(_phost);
Gpu_Hal_WaitCmdfifo_empty(_phost);

I need to load my custom font to be able to make my black background transparent for my icons.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 734
    • View Profile
Re: How to make a selected color transparent?
« Reply #7 on: June 21, 2021, 01:49:13 PM »

Hello,

Thanks for the details, the developers have investigated this behaviour and noted that it is outwith the intended use case for CMD_SETFONT2.

The suggest converting the PNG with the black background into an L8 formatted bitmap, and not this should achieve the same effect (removing the background and making the image transparent).

Best Regards,
BRT Community
Logged