Skip to main content
kweisi50
Associate III
May 22, 2019 7:44 AM UTC
Solved

How to switch a bitmap image between transparent and opaque.

Hi,

I have small bitmap in a window, which normally I would like it appear to be transparent (invisible) but when a flag is set to become fully opaque, when the flag is cleared go back to being fully transparent.

Kind Regards

MikeZ

This topic has been closed for replies.
eng23
eng23Best answer
Senior
May 22, 2019 12:38 PM UTC

Hi,

Have you tried "imageX.setVisible(flag);" ?

4 replies

eng23
eng23Best answer
Senior
May 22, 2019 12:38 PM UTC

Hi,

Have you tried "imageX.setVisible(flag);" ?

Martin KJELDSEN
Principal III
May 23, 2019 8:53 AM UTC

Hi @kweisi50​,

You can either use setVisible(), as suggested by @eng23​, or use setAlpha():

//Set invisible
image.setAlpha(0); 
image.setVisible(false);
 
//Set fully visible
image.setAlpha(255); 
image.setVisible(true);

kweisi50
kweisi50Author
Associate III
May 24, 2019 10:00 AM UTC

Hi Martin/eng23,

Sorry for the delay in replying, thanks for you solution.

MikeZ

Martin KJELDSEN
Principal III
May 24, 2019 10:59 AM UTC

You're welcome!