BogdanovKirill / RtspClientSharp

Pure C# RTSP client for .NET Standard without external dependencies and with true async nature. I welcome contributions.
MIT License
706 stars 284 forks source link

Center the video frame #48

Open folibis opened 5 years ago

folibis commented 5 years ago

So far I use the following code:

            _width = width;
            _height = height;
            _dirtyRect = new Int32Rect(0, 0, width, height);

            _transformParameters = new TransformParameters(RectangleF.Empty,
                    new System.Drawing.Size(_width, _height),
                    ScalingPolicy.RespectAspectRatio, PixelFormat.Bgra32, ScalingQuality.FastBilinear);

            myWiteableBitmap = new WriteableBitmap(
                width,
                height,
                ScreenInfo.DpiX,
                ScreenInfo.DpiY,
                PixelFormats.Pbgra32,
                null);

            RenderOptions.SetBitmapScalingMode(myWiteableBitmap, BitmapScalingMode.HighQuality);

where _width and _height are the size of the WriteableBitmap. But in case the frame size rate is different from the bitmap one the video is rendering as left aligned. How can I center it? #

BogdanovKirill commented 4 years ago

Hello,

Did you resolve this issue? It seems that you need to modify some code in Invalidate method of VideoView.xaml.cs. I think that _writeableBitmap.BackBuffer should be replaced by _writeableBitmap.BackBuffer + offset, where offset could be calculated through frame width and pixel size