private NormalizedRect GetDestRectangle() { int hr = 0; int width, height, arW, arH; NormalizedRect rect = new NormalizedRect(); hr = windowlessCtrl.GetNativeVideoSize(out width, out height, out arW, out arH); DsError.ThrowExceptionForHR(hr); // Position the bitmap in the middle of the video stream. if (width >= height) { rect.top = 0.0f; rect.left = (1.0f - ((float)height / (float)width)) / 2; rect.bottom = 1.0f; rect.right = rect.left + (float)height / (float)width; } else { rect.top = (1.0f - ((float)width / (float)height)) / 2; rect.left = 0.0f; rect.right = rect.top + (float)width / (float)height; rect.bottom = 1.0f; } return(rect); }
private void SetSize() { var srcRect = new DsRect(); var dstRect = new DsRect(ClientRectangle); int arWidth, arHeight; _windowlessControl.GetNativeVideoSize(out srcRect.right, out srcRect.bottom, out arWidth, out arHeight); _windowlessControl.SetAspectRatioMode(VMR9AspectRatioMode.LetterBox); _windowlessControl.SetVideoPosition(srcRect, dstRect); }
public override void GetNativeVideoSize(out int width, out int height, out int arWidth, out int arHeight) { _pVMRWindowlessControl9.GetNativeVideoSize(out width, out height, out arWidth, out arHeight); }