LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange behaviour of PNGs with transparent background

Solved!
Go to solution

Hello all,

I am facing a strange problem on an application of mine that I'm upgrading. The application is written in CVI2009SP1 and is already running at customer site. I am now adding some new functionality and have made a few modifications in the application UIR file, and suddenly all the images I have show a black background instead of the transparent one.

The strange thing is that I see the images correctly in the UIR editor, the black background being shown only at runtime, no matter if debug or release.

 

This is an example of wat I'm seeing:

ProblemWithTransparent.PNG

 

I tried reloading the image in the control after checking transparency but situation didn't change. The problem relates only to images in .PNG format, other images in .ICO format do show correctly.

 

I see this behaviour in my office on two machines both wirth 2009SP1 for development and runtime 2012SP1. The same happens on the customer PC with runtime 2010SP1 and no IDE installed. If I run the original application with unmodified UIR, transparency is correctly handled. I am not operating programmatically on the images, which are only decorative elements on the user interface.

 

What can be happening?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 1 of 11
(5,518 Views)

Hi Roberto,

is this problem occurring only with that specific UIR or also with a new UIR with the same png files imported?

How did you load the png images? Using a picture control and selecting "Load Image" when editing it?

What happens if you reload the images?

Bye,

 

Licia

0 Kudos
Message 2 of 11
(5,490 Views)

Hello Licia,

the problem is related to a single UIR file that I derived modifying some controls from a previous version (developed in the same CVI release) and saving it with a different name. At present other programs I am developing are not affected from this bug.

I was able to reduce the problem to the small sample I am attaching to this message.

 

Images are simple picture controls with PNGs loaded at design time, no modification occurs at runtime. Picture controls are set without frame and with transparent background.

It appears as if something got corrupted in this UIR file; by the way I was able to heavily modify it in order to create the sample deleting all non-interesting controls from the panel and all other panels and menu bars from the file, but it still exhibits the same behaviour.

I then pasted on this panel the same picturs taken from the previous, correct panel: they show the same behaviour.

I then created new picture controls loading the same pictures, with still no effect.

Even saving the file in text format and reloading it has no effect!|

The effect seems limited to .PNG images: .ICO images behave normally.

 

In the attached sample I have added two screenshots: panel as it appear in the UIR editor and panel as it appears at runtime. As you can see there are some differences at design time, but all images are black at runtime.

 

(Note: while I was writing this message I went back to the sample and found that closing and reopening the UIR file made images corrupt even in the UIR editor. As you can see in the screenshot, same images were different before).



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 11
(5,450 Views)

Hi Roberto,

I opened your project in CVI 2013 and run the code.

In attachement you can see a screenshot of what I am seeing: the images seem to remain the same...

Bye,

 

Licia

0 Kudos
Message 4 of 11
(5,426 Views)

Yes, but... all of them should have a transparent background Smiley Surprised

 

They indeed had before something happened to the UIR file.

And if I place the same images on another UIR file they show the correct background.

And if I copy one of the problematic picture controls on that different panel and reload the image, the background is transparent.

 

Can you load an image of yours (PNG with transparent background) in the picture controls and see what happens?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 11
(5,420 Views)

Roberto,

 

just another stupid comment of mine: Could it be that when modifying your UI you forgot about a transparent picture control...:

 

PNG images with alpha-channel transparency lose their transparency when displayed on transparent classic-style picture controls

0 Kudos
Message 6 of 11
(5,416 Views)

Hello wolfgang, thanks for the hint but no: all controls in application file as well as the sample project I posted are lab-style picture controls.

Moreover, I have not modified those controls when upgrading the UIR, and the previous version still behaves correctly. Smiley Frustrated



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 7 of 11
(5,406 Views)

Hi Roberto,

I created a simple png file with a trasparent background (it is attached) and loaded it in a new picture control on your UIR file.

I reproduced the problem, with the picture showing a black background. When saving the UIR file, I got the attached error.

Transparency is correctly kept when loading my png on every other uir file.

I tested in CVI 2013.

Bye,

 

Licia

Download All
0 Kudos
Message 8 of 11
(5,366 Views)

The error probably originates from saving in 2013 a UIR that was created in 2009.

 

Ok, so you see the problem: can the UIR be fixed somehow or do I need to rebuild it from scratch? And how can this problem originate? I'm asking since I constantly upgrade my applications by modifying previous UIR files and saving them with a different name. I would like to avoid this problem on other applications, if I can.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 9 of 11
(5,358 Views)

Hi Roberto,

I tried to save your UIR file as text file (tui file) as described here. I then loaded from this text file the UIR: I was able to add picture controls with the transparent png and have them correctly displayed also at runtime.

Try this option and let me know if it works.

Bye,

 

Licia

0 Kudos
Message 10 of 11
(5,335 Views)