Im using C# in VS2017 and have a Vlc Control to play a video.
I want to overlap some part of the video with a PNG image with transparency. In VS2017, elements are transparent to their parent. So, to make the image be transparent to the video I have to set it as child of the video.
But if I do that, the image doesn't display at all. Video is always refreshing and overlapping the image (even if I do a constant BringToFront in the image).
So, I change the Parent of the image to the form. Now the image displays, but through it's transparency I see the form's background, not the video.
Target platform is Windows. Is there any solution for this?
I had this same problem with windows forms. I believe there is no simple solution where you can use another control (e.g a picturebox) and make it transparent such that you can see the video behind it.
One thing you can do is to create another form, set it as topMost, set it's MDiParent to the form containing the VLC control and set its FormBorderStyle to None. Then set it's background to be the image you want to overlay and set it's opacity property to say 50%. This should give you the effect you want but it is a bit of a work around.
If you can you should move to WPF as your UI technology which should solve this and allow you to overlay a picture box with a transparency that doesn't just show the background of the main form behind it and actually shows the video.
It's not very clear how you're using libvlc.
Do you have to blend the image with the control itself? Shouldn't you blend any given image with the video frames?
If so, try using --alphamask-mask filter:
--alphamask-mask=<string>
Transparency mask
Alpha blending transparency mask. Uses a png alpha channel.
If you're using libvlc.net you can do this by adding an option:
vlcContext.StartupOptions.AddOption(<options>);
Related
I'm looking for a way to have images on invisible form that allow alpha transparency and allow to place and use buttons/labels etc.
I've tried this Transparent background on winforms?, layered window and many more, nothing fully successful. I've ended up with such failures http://imgur.com/a/t6nmF
Transparency key only makes one color transparent, which doesn't work on images that have smooth color gradients on the edges.
First of all, are you certain that your image has a transparent background?
Layered window is exactly what you should use to achieve the desired effect. Since you don't give much details, I don't know what's wrong with your implementation. Try to use the PerPixelAlphaForm from the following article: Per Pixel Alpha Blend in C#. When used correctly, it will work (even though the article is really old).
I've built an app which uses transparent PNGs to display an overlay for users to tap using WPF and C#. However, there are weird jagged edges around the words. Would this be more of a C#/WPF limitation or a Photoshop issue?
Screen resolution is 720p. App runs on win7pro.
Screenshot:
Definitely a problem with the image itself. I see the same fringing when viewing the image against a black background on my phone. Make sure you compose the text over a transparent background (i.e., don't remove the background with a magic wand tool) and save with a full alpha channel (32-bit PNG).
I have a WinForm and I set a transparent PNG image for the label. In Windows XP, the transparency displays properly, but in Windows 7, the white text (as seen in the example URL below) becomes transparent (it should be solid white). I'm also wondering if there is a way to smooth the edges of the transparent image so it isn't as choppy.
label1.Image = global::WinProgram.Properties.Resources.image_name;
Example:
Due to your limited code, I'd be guessing on this one but i find this very likely to be your problem. In WinForms there is a so called TransparencyKey, I'm guessing that you sett'd the SolidWhite as your TransparencyKey.
You can refer to this post: Transparent Background
I've form in .net C#,
Problem:
I've a PNG image with drop shadow and I want put that image as back ground image of form and also using transparency key as well with the same background color property. But when I debug my app it does not give expected drop shadow as per png image. Please help me.
You'll probably need to programmatically adjust the transparency of the image.
Background images on a form do not support any photo attributes/editing, just set or get. So you'll need to get your photo and the background color of the form, and then programmatically change the photo to look as if it is transparent to the background color of the image.
Then take the image and set it as the background image of the form.
But without more information, I'm not sure what else to say or if I've said the right thing.
I have a better solution.
ModernUI Theme for .Net WinForms supports two kinds of Shadow Effects. See
image below.
WinForm ModernUI
It's under MIT on GitHub:
https://github.com/NetDimension/WinForm-ModernUI
I have a requirement to play a video file in C# (with audio) then to be able to fade out the video to a black screen then fade in another video.
I've looked at DirectShow & DirectShowNet however I'm none the wiser. I've got a simple app to play a video with a time counter etc, however I'm flummoxed with filters & graphs.
What direction do I need to go in?
Create a WPF Apllication and use the MediaElement Control to play the videos. Use the events of the MediaElement (for example MediaEnded) to detect when to start fadeout / switch streaming source / fadein. The easiest way for the fadeout is to change opacity of the Mediaelement.
The MediaElement should be able to play all videos which have a directshow filter installed on your system.
Are you using WPF?
With WPF you could do this in a variety of ways. eg you could simply animate the video control's (MediaElement) opacity.
NOTE: you can use WPF controls inside of a Winforms app. See this video for how to do this.
One solution, although I would consider it a hack, would be to draw a black overlay ontop of the viewable area of the video. You can adjust the transparency of the overlay based on the frame/time of the video. Essentially, you would fire off a timed event that would slowly remove or add transparency to the overlay based on where in the video you want to starting fading.