From: Henri Verbeet hverbeet@locutus.nl
--- dlls/quartz/vmr7_presenter.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/dlls/quartz/vmr7_presenter.c b/dlls/quartz/vmr7_presenter.c index 72571a299cb..6c6c2f350e1 100644 --- a/dlls/quartz/vmr7_presenter.c +++ b/dlls/quartz/vmr7_presenter.c @@ -146,6 +146,7 @@ static HRESULT WINAPI image_presenter_PresentImage(IVMRImagePresenter *iface, DWORD_PTR cookie, VMRPRESENTATIONINFO *info) { struct vmr7_presenter *presenter = impl_from_IVMRImagePresenter(iface); + SIZE dst_size; HRESULT hr; RECT rect;
@@ -167,6 +168,26 @@ static HRESULT WINAPI image_presenter_PresentImage(IVMRImagePresenter *iface, return E_FAIL; }
+ dst_size.cx = rect.right - rect.left; + dst_size.cy = rect.bottom - rect.top; + + if (info->szAspectRatio.cx * dst_size.cy > dst_size.cx * info->szAspectRatio.cy) + { + unsigned int scaled_height = info->szAspectRatio.cy * dst_size.cx / info->szAspectRatio.cx; + unsigned int offset = (dst_size.cy - scaled_height) / 2; + + rect.top += offset; + rect.bottom -= offset; + } + else if (info->szAspectRatio.cx * dst_size.cy < dst_size.cx * info->szAspectRatio.cy) + { + unsigned int scaled_width = info->szAspectRatio.cx * dst_size.cy / info->szAspectRatio.cy; + unsigned int offset = (dst_size.cx - scaled_width) / 2; + + rect.left += offset; + rect.right -= offset; + } + if (FAILED(hr = IDirectDrawSurface7_Blt(presenter->primary, &rect, info->lpSurf, NULL, DDBLT_WAIT, NULL))) ERR("Failed to blit, hr %#lx.\n", hr);