Cool-LV Posted December 18, 2008 Report Share Posted December 18, 2008 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...... Quote Link to comment
LAVA 1.0 Content Posted December 18, 2008 Report Share Posted December 18, 2008 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 Quote Link to comment
Cool-LV Posted December 18, 2008 Author Report Share Posted December 18, 2008 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 @! Quote Link to comment
vugie Posted December 18, 2008 Report Share Posted December 18, 2008 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. Quote Link to comment
Cool-LV Posted December 18, 2008 Author Report Share Posted December 18, 2008 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, and dynamically load PNG or GIF image, it is nice too. :thumbup: Quote Link to comment
Cool-LV Posted December 19, 2008 Author Report Share Posted December 19, 2008 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! Quote Link to comment
PJM_labview Posted December 19, 2008 Report Share Posted December 19, 2008 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 Quote Link to comment
Cool-LV Posted December 19, 2008 Author Report Share Posted December 19, 2008 QUOTE (PJM_labview @ Dec 18 2008, 06:25 PM) Ton, is correct.I have code that I wrote a while ago that do just that and it works like a charm. PJM Hi PJM, Then, would you share that simple code for study ? thanks ?!~ Quote Link to comment
Eugen Graf Posted December 19, 2008 Report Share Posted December 19, 2008 May be the solution from Andrey can help: http://forums.ni.com/ni/board/message?boar...ding&page=2 That was my problem too... Quote Link to comment
PJM_labview Posted December 20, 2008 Report Share Posted December 20, 2008 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 Quote Link to comment
Yair Posted December 21, 2008 Report Share Posted December 21, 2008 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? Quote Link to comment
PJM_labview Posted December 21, 2008 Report Share Posted December 21, 2008 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 Quote Link to comment
Yair Posted December 22, 2008 Report Share Posted December 22, 2008 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. Quote Link to comment
viSci Posted December 22, 2008 Report Share Posted December 22, 2008 Here is an example of the code I wrote to do alpha blending Quote Link to comment
Cool-LV Posted December 22, 2008 Author Report Share Posted December 22, 2008 Thanks All your guys, all of you are very kind, I appreciate ! maybe, I hadn't gave the clear question, all your help is focus the transparent effect, actually, I want to display the PNG image with its original face. where is translucent where it should be, it is not making whole image is transparent. Quote Link to comment
Phillip Brooks Posted December 23, 2008 Report Share Posted December 23, 2008 QUOTE (Cool-LV @ Dec 21 2008, 08:17 PM) Thanks All your guys, all of you are very kind, I appreciate !maybe, I hadn't gave the clear question, all your help is focus the transparent effect, actually, I want to display the PNG image with its original face. where is translucent where it should be, it is not making whole image is transparent. I think you've confused everyone by using the word 'translucent' (wikipedia). What you seem to be describing now are transparent regions. If you want to combine overlapping images with transparent areas, you would create a masks of the images to be merged... Use the Create Mask (not in base package) function. Quote Link to comment
PJM_labview Posted December 23, 2008 Report Share Posted December 23, 2008 I think the misunderstanding might not be with us. The method I described earlier works regardless how many transparent area there are in the image. Below is another short video using a more complex (transparency wise) image. PJM Quote Link to comment
Yair Posted December 23, 2008 Report Share Posted December 23, 2008 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. Quote Link to comment
Cool-LV Posted December 23, 2008 Author Report Share Posted December 23, 2008 thanks all,specially thanks PJM, the function is so cool(from the video, that is what I need ), but the "Create mask.vi" can't not make translucent effect. just transparent. I have no idea to deal with it. Quote Link to comment
Cool-LV Posted December 24, 2008 Author Report Share Posted December 24, 2008 Wow, I made it, Thanks PJM again (ResultingColor = SourceColor × alpha / 255 + BackgroundColor × (255 - alpha) / 255, it works :thumbup: ) and all you guys. :laugh: Quote Link to comment
Yair Posted December 24, 2008 Report Share Posted December 24, 2008 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. Quote Link to comment
Dirk J. Posted January 2, 2009 Report Share Posted January 2, 2009 I think you can also use the PictureBox .Net control. It blends automatically with the background. Quote Link to comment
Cool-LV Posted January 6, 2009 Author Report Share Posted January 6, 2009 QUOTE (Dirk J. @ Jan 1 2009, 04:31 PM) I think you can also use the PictureBox .Net control. It blends automatically with the background. OH yeah, Upstairs's handle is so easy! nice. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.