LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with READ PNG FILE

Solved!
Go to solution

And here you see how I load the pictures from skin path to the front panel picture controls.

 

 

Message Edited by Eugen Graf on 11-06-2008 06:09 PM
0 Kudos
Message 11 of 17
(1,833 Views)

I see there are no solutions/suggestions how to do that. Is it not possible?

 

Thank you, Eugen

0 Kudos
Message 12 of 17
(1,795 Views)

You can code this yourself by blending the pixels of two images. For that, you need to:

  1. Get the image data of both the background and foreground images.
  2. Tke them apart to their RGB components (by using Split Number).
  3. Calculate the new value for each RGB component for each pixel by getting the difference and adding the percentage you want (e.g. if the BG pixel R is 50 and the FG R is 100 and you want 30% merging, the resulting R will be 65). You get the percentage by reading the alpha channel which is actually loaded from the file and put into the picture control data as the upper or lower byte in the U32 image data.
  4. Join the data back to a U32 array.
  5. Build the picture.

The code is actually pretty simple, but I seem to remember some change in the way this worked between 7.x and 8.x, where 8.x seems to do this differently. I didn't pursue this, so I don't know if it's a bug.

 

Also, this won't work with Andrey's example, since the Get Panel Image method does not currently capture the background images in VIs.


___________________
Try to take over the world!
Message 13 of 17
(1,791 Views)

Hi, Eugen,

 

Sure its possible. Impossible is nothing...

But this may be a little bit complicated. In general you RGB image with transparensy organized by following way - four bytes ber pixel (Transparency, R, G, B).

What NI does is comparizon Transparency byte with threshold, in if transpareny less than threshold, then pixel marked as transparent. So, you have "binary" transparensy (in the fact result of comarizon added to the Mask array where each bit responcible for transparency.

What you needed is to analyse background under the picture and then modify colors of the image according to the transparensy byte.

This may be complicated if you have pattern under the picture control (like clouds in the given example). But this may be more easy for solid color background.

For example, if your backround is Black, and picture is Red, then you can just write Transparency value to the Red channel and then get this "semitransparency antializing effect":

 

 

Otherwise you should perform some calculation between picture color, transparency value and background color.

 

best regards,

Andrey.

Message Edited by Andrey Dmitriev on 11-07-2008 11:11 AM
Download All
Message 14 of 17
(1,789 Views)

Oh, thank you for suggestion, I will try it!

May be my background picture (800X600) will not be monocolor and I'll should extract only the field, where icon picture should be placed, but it's an another problem.

 

Eugen

0 Kudos
Message 15 of 17
(1,784 Views)

Ok, thank you for solutions. I will do that. I want/should to make my background picture always in black (the best color to drive in a car), else it's almost impossible (very difficult issue) to adapt the picture to the background.

 

Regards, Eugen

 

P.S. but if I do so, than I don't need transparency. I can draw my icons without transparency (no alpha channel) on the black background. Hmm...

Message Edited by Eugen Graf on 11-07-2008 04:39 AM
0 Kudos
Message 16 of 17
(1,778 Views)

thanks to everyone...

 

the problem was with the png file i've created using  gimp...the background seems to be transparent, but when loaded in labview it produced a dark background...

 

thanks again to you all...

 

RENN 

Kudos always welcome for helpful posts 🙂
0 Kudos
Message 17 of 17
(1,734 Views)