vpinball / b2s-backglass

B2S Backglass Server for use with Visual Pinball
Other
39 stars 7 forks source link

Allow transparency on Backglass, DMD and Background to active #35

Open JockeJarre opened 1 year ago

JockeJarre commented 1 year ago

It should be possible to activate transparency on Backglass, DMD and Background and set the TransparencyKey to a value from the PNG file included (for backglass and DMD) or loaded (for background)

tommkell commented 8 months ago

Does this mean we could cut out where the alphanumerics go + add a transparent layer like shiny plastic, then have freezys in behind it? Would be unreal :)

JockeJarre commented 8 months ago

It has shown not to be that easy to solve, even if B2S supports it, there are so many other components involved which B2S does not control.

tommkell commented 8 months ago

I suppose it would have been done already if it was that easy! Thanks for the reply 👍

5cutters commented 6 months ago

As far as i can tell the base64 encoding for the images already includes transparency when the B2S files are created, it's just that they are then shown on top of a black form background.

A user defined RGB transparencykey could work for regular shapes but would probably have problems with alpha blending (so would allow fully opaque or fully transparent only)

A better(?) solution (more flexible but more complex) might be to use UpdateLayeredWindow type api calls - see example https://github.com/BCProgramming/AlphaSample

JockeJarre commented 6 months ago

work for regular shapes but would probably have problems with alpha blending (so would allow fully opaque or fully transparent only) yes, you are right.

A better(?) solution (more flexible but more complex) might be to use UpdateLayeredWindow type api calls - see example

I compiled and it seems to do the work. You seem familiar with the technique? Any chance you can try it out?

5cutters commented 6 months ago

Not much time at the moment and i'm not overly familiar with the technique (i've seen it used so i know it exists but never used it myself), so might be a while before i get round to it.

JockeJarre commented 6 months ago

Would love to get some support even if it is just for short period to test out some new techniques... I did some different tries myself to get transparency into the forms, but it always failed that the main window only does one specific color transparent.

5cutters commented 5 months ago

I had a quick look at the code. Bad news i'm afraid, the B2S stuff appears to use a range of controls and graphics methods to update the displayed image on the form(s). As i understand it, for the 'layered' method to work it'd need to change to update a bitmap for the display instead, and that'd be a big old change. TransparencyKey with no alpha blending is probably the best option here as a winform project, so only one specific RGB value as transparent as you found :(

JockeJarre commented 5 months ago

thanks for your investigations. I found similar information in this. What I understand is WPF much better in handling transparency and it should be possible to mix WPF with win forms? Maybe that is an option?

Otherwise Jason (jsm174), working on the standalone version, has ported B2S to linux/SDL. So another option would be to port it back to windows, and then there might be a chance?

5cutters commented 5 months ago

Not much experience with WPF, but yes it is my understanding too that transparency handling (with alpha blending) would be a lot easier there.