Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Howto change PreviewPort after cam.Camera.PreviewPort.ConnectTo(video) #205

@clahil-linum

Description

@clahil-linum

I want to use something like the code below (in a WinForm) the get the screen location of a picture box:

Point previewPos = PointToScreen(QrCodePreview.Location);
            Rectangle screenPosition = new Rectangle(previewPos.X, previewPos.Y, QrCodePreview.Width, QrCodePreview.Height);

This works fine a give me the current screen location of a previewbox inside the WinForm dialog. After this I want to use code like the one below to attach the camera preview port to that screen location:

PreviewConfiguration previewConfig = new PreviewOverlayConfiguration
            {
                FullScreen = false,
                PreviewWindow = screenPosition,
                Layer = 1,
                Opacity = 255
            };
var video = new MMALVideoRenderer(previewConfig);
cam.Camera.PreviewPort.ConnectTo(video);

This works fine to. I get a very fast preview of the camera that is overlayed onto the picturebox item inside the dialog. But obviously as soon as I move and/or resize the dialog the screen coordinates of the preview port must be updated. I tried code like to one above inside a "changed size/position" handler but new settings had no effect. It seems that I miss something to attach a new previewport configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions