From 72a1fe85cb6064323bfd9f9d1ab8246b06d9ce1d Mon Sep 17 00:00:00 2001 From: aymeric <aymeric@3f6dc0c8-ddfe-455d-9043-3cd528dc4637> Date: Fri, 2 Oct 2009 15:54:05 +0000 Subject: [PATCH] fix windows display to keep ratio and fill with black. git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@693 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/mediastreamer2/src/videoout.c | 55 ++++++++++++++++++-------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/linphone/mediastreamer2/src/videoout.c b/linphone/mediastreamer2/src/videoout.c index c31846d1a0..16c727db26 100644 --- a/linphone/mediastreamer2/src/videoout.c +++ b/linphone/mediastreamer2/src/videoout.c @@ -269,6 +269,8 @@ static LRESULT CALLBACK window_proc( LPARAM lParam) // second message parameter { switch(uMsg){ + case WM_PAINT: + break; case WM_DESTROY: break; case WM_SIZE: @@ -463,6 +465,11 @@ static void win_display_update(MSDisplay *obj){ BITMAPINFOHEADER bi; RECT rect; bool_t ret; + int ratiow; + int ratioh; + int w; + int h; + if (wd->window==NULL) return; hdc=GetDC(wd->window); if (hdc==NULL) { @@ -481,21 +488,11 @@ static void win_display_update(MSDisplay *obj){ bi.biCompression=BI_RGB; bi.biSizeImage=wd->rgb_len; - if (wd->last_rect_w!=rect.right || wd->last_rect_h!=rect.bottom) - { - ret=DrawDibDraw(wd->ddh,hdc,00,00, - rect.right,rect.bottom, - &bi,wd->black, - 0,0,bi.biWidth,bi.biHeight,0); - wd->last_rect_w=rect.right; - wd->last_rect_h=rect.bottom; - } - - int ratiow=wd->fb.w; - int ratioh=wd->fb.h; + ratiow=wd->fb.w; + ratioh=wd->fb.h; reduce(&ratiow, &ratioh); - int w = rect.right/ratiow*ratiow; - int h = rect.bottom/ratioh*ratioh; + w = rect.right/ratiow*ratiow; + h = rect.bottom/ratioh*ratioh; if (h*ratiow>w*ratioh) { @@ -511,9 +508,35 @@ static void win_display_update(MSDisplay *obj){ if (h*wd->fb.w!=w*wd->fb.h) ms_error("wrong ratio"); + //if (wd->last_rect_w!=rect.right || wd->last_rect_h!=rect.bottom) + { + ret=DrawDibDraw(wd->ddh,hdc,0,0, + (rect.right-w)/2,rect.bottom, + &bi,wd->black, + 0,0,bi.biWidth,bi.biHeight,0); + + ret=DrawDibDraw(wd->ddh,hdc,0,0, + rect.right,(rect.bottom-h)/2, + &bi,wd->black, + 0,0,bi.biWidth,bi.biHeight,0); + + ret=DrawDibDraw(wd->ddh,hdc,0,rect.bottom-(rect.bottom-h)/2, + rect.right,(rect.bottom-h)/2, + &bi,wd->black, + 0,0,bi.biWidth,bi.biHeight,0); + + ret=DrawDibDraw(wd->ddh,hdc,rect.right-(rect.right-w)/2,0, + (rect.right-w)/2,rect.bottom, + &bi,wd->black, + 0,0,bi.biWidth,bi.biHeight,0); + + wd->last_rect_w=rect.right; + wd->last_rect_h=rect.bottom; + } + ret=DrawDibDraw(wd->ddh,hdc, - rect.right/2-(w/2), - rect.bottom/2-(h/2), + (rect.right-w)/2, + (rect.bottom-h)/2, w, h, &bi,wd->rgb, -- GitLab