0

The idea

I am making a Windows.Forms application using C#. There are three AXIS M7001 video encoders providing H264-converted stream over RTSP protocol. I want to take these streams (the cameras are put together), cut them properly and get a single wide-angle live video, on which I'd be able to add pictures and paint lines. So i need a way to paint and update dozens of lines on top of all three streams, and to put a single picture with transparent background.

The problem

There is a SDK provided by Axis (Axis Media Control SDK, AMC), which is actually a single library with a class inherited from the Control class. They provide a couple of methods for drawing on the AMC object, which support just graphic primitives like lines, ellipses and rectangles.

The drawing methods by AMC do not let me make an overall drawing on top of the final video stream. It also doesn't support adding overlaying pictures.

The AMC control does not let me put anything transparent in front of it. Either the background of the panel/picturebox becomes opaque (taken from Form.BackColor) or both the background and foreground get hidden.

The Google

I've tried the following idea with overriding Panel and PictureBox

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams createParams = base.CreateParams;
            createParams.ExStyle |= 0x00000020; // WS_EX_TRANSPARENT
            return createParams;
        }
    }

    protected override void OnPaintBackground(PaintEventArgs e)
    {
        // Do not paint background.
    }

It lets me put a transparent Panel on top of the AMC and handle mouse events, but if I put something on the panel or add some OnPaint event, I can't see it. Trying overriden PictureBox has no result.

Of course, anything like

BackColor = Color.Transparent;

doesn't work either.

Godmar
  • 31
  • 3
  • Please see this: [Painting custom background of parent and parent children in C#](http://stackoverflow.com/questions/29031771/painting-custom-background-of-parent-and-parent-children-in-c-sharp/29032020#29032020). This isn't very good *performance-vise* though, I'm not sure it will solve your problem. If you just need mouse input a global mouse hook sounds a lot better. – bokibeg Mar 18 '15 at 15:36
  • You can always get it going by overlaying a top-level a window over the control. Same idea [as this](http://stackoverflow.com/a/4503371/17034) but use TransparencyKey instead of Opacity. – Hans Passant Mar 18 '15 at 15:52
  • @HansPassant Thank you, that completely works for me, allowing to add more paint layers. – Godmar Mar 23 '15 at 10:20

0 Answers0