Jump to content

I wish LV can display translucent PNG or GIF image


Cool-LV

Recommended Posts

as my subject, I wish LV can handle or display translucent PNG or GIF image on picture control, sometimes, my PNG image's edge is having translucent looking but LV can not display its realistic face, the edge part lose something, and I have to use Web ActiveX to display it, but this kind of ActiveX is differently handle image data......

Link to comment

QUOTE (Ton @ Dec 17 2008, 08:04 AM)

Or you could build your own, the image data returned from a read png file contains the alpha blending info, if you really want to you could write your own alpha-blending routine.

You would need to get the image behind the picture control and do your calculation but that should be doable.

Ton

All right, Ton, I enclosed simple code, there are my query on front panel, I don't think it can be done. Please give your thread, thanks @!

Link to comment

QUOTE (vugie @ Dec 17 2008, 09:32 AM)

Also when you put image on front panel as a decoration transparency smoothness is preserved. I was playing around with scripting trying to dynamically change such decoration, but without success.

Oh Yup, if we can regard the front panel as a huge picture control, :yes: and dynamically load PNG or GIF image, it is nice too. :thumbup:

Link to comment

QUOTE (vugie @ Dec 17 2008, 09:32 AM)

Also when you put image on front panel as a decoration transparency smoothness is preserved. I was playing around with scripting trying to dynamically change such decoration, but without success.

and, I find LabVIEW platform an internal function which is "import picture to clipboard", it is powerful function, it can import many format image, e.g. Jpeg, Bmp, PNG and GIF, animation too, Wow, how NI does this, if we can call this function(even Scripting), it is nice, because We can get image from clipboard. but I fail, though I enabled LabVIEW scripting too.

and I found, if import an animated GIF picture to clipboard, add loop for get image from clipboard and run this code,you would find, the image displaying on picture control is animated too!

Link to comment

QUOTE (Ton @ Dec 16 2008, 11:04 PM)

Or you could build your own, the image data returned from a read png file contains the alpha blending info, if you really want to you could write your own alpha-blending routine.

You would need to get the image behind the picture control and do your calculation but that should be doable.

Ton

Ton, is correct.

I have code that I wrote a while ago that do just that and it works like a charm.

PJM

Link to comment

QUOTE (Cool-LV @ Dec 18 2008, 04:24 PM)

Hi PJM,

Then, would you share that simple code for study ? thanks ?!~

I am sorry, but I can't share this code.

Here is more info that should help.

As other have mentioned, after reading a PNG file the image data cluster does has the alpha blending info in the image array as [ARGB] (Alpha Red Green Blue).

Once you got the image data of the pixels directly "behind" you new image, you could now recompute each new pixel color with:

ResultingColor = SourceColor × alpha / 255 + BackgroundColor × (255 - alpha) / 255

Note: You need to operate on color plane not on LV color.

I hope this help.

PJM

Link to comment

I've done this in the past as well and I can also say the code is quite simple (although I can't share mine either). If you do this, maybe you should post your code to both threads. You can get the color info by unflattening the pixmap and then splitting and joining the 2D arrays or by taking the data directly from the 1D image array and you can get the transparency info from every fourth element in the image array (e.g. by using the decimate array primitive).

Philippe, as I mentioned in the other thread, my code which worked fine in 7.0 doesn't really work in 8.6 and sort of messes up the picture. I didn't look into this, so I don't know the details, but did you run into anything like that?

Link to comment

QUOTE (Yair @ Dec 20 2008, 08:27 AM)

Philippe, as I mentioned in the other thread, my code which worked fine in 7.0 doesn't really work in 8.6 and sort of messes up the picture. I didn't look into this, so I don't know the details, but did you run into anything like that?

Nope. Still works fine for me (see below).

Note: Watch the little gradient block as I move it in the image.

PJM

Link to comment

Well, the image I saw this happen with has more complex transparency than that and since the code did work fine in 7.0, I would have to blame 8.x. However, as I mentioned, I didn't look into this at all other than seeing that it happened, so the fix would probably not be too hard.

Link to comment

I would have to agree with PJM. If you look at the last video he posted, you can see this very clearly in the shadows cast by the sequence in the LV logo.

The LabVIEW picture control functions load the alpha channel from PNGs, but the VIs that draw the image discard it. That's why you need to get both the FG and BG image and do the merging yourself. I explained this in more detail in the other thread.

Link to comment

Well, if you came up with something, I suggest you post it to both threads in case someone else will want it in the future.

I can say that the code Mike posted already does almost everything you need. It took me about a minute to modify it to handle alpha blending for the entire array and plug it into my code and it worked nicely in 8.6. I guess that means that the algorithm I originally used was wrong, but it's interesting that it did work fine in 7.0.

Link to comment
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.