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

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

Open
clahil-linum opened this issue Jul 21, 2022 · 0 comments
Open

Comments

@clahil-linum
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant