RtspClientSharp icon indicating copy to clipboard operation
RtspClientSharp copied to clipboard

Center the video frame

Open folibis opened this issue 6 years ago • 1 comments

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? #

folibis avatar Aug 22 '19 08:08 folibis

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

BogdanovKirill avatar Sep 17 '19 07:09 BogdanovKirill