Off-by-ones in windows/GDI window calculations

Check for "gutter" around displayed image. there was one row/column missing on the bottom/right.
Might as well set gutter = 0?
pull/13451/head
Christoph Rackwitz 6 years ago
parent ff8c53ea20
commit beba82b22b
  1. 22
      modules/highgui/src/window_w32.cpp

@ -1131,20 +1131,20 @@ static void icvUpdateWindowPos( CvWindow* window )
{ {
RECT rmw, rw = icvCalcWindowRect(window ); RECT rmw, rw = icvCalcWindowRect(window );
MoveWindow(window->hwnd, rw.left, rw.top, MoveWindow(window->hwnd, rw.left, rw.top,
rw.right - rw.left + 1, rw.bottom - rw.top + 1, FALSE); rw.right - rw.left, rw.bottom - rw.top, FALSE);
GetClientRect(window->hwnd, &rw); GetClientRect(window->hwnd, &rw);
GetWindowRect(window->frame, &rmw); GetWindowRect(window->frame, &rmw);
// Resize the mainhWnd window in order to make the bitmap fit into the child window // Resize the mainhWnd window in order to make the bitmap fit into the child window
MoveWindow(window->frame, rmw.left, rmw.top, MoveWindow(window->frame, rmw.left, rmw.top,
rmw.right - rmw.left + size.cx - rw.right + rw.left, size.cx + (rmw.right - rmw.left) - (rw.right - rw.left),
rmw.bottom - rmw.top + size.cy - rw.bottom + rw.top, TRUE ); size.cy + (rmw.bottom - rmw.top) - (rw.bottom - rw.top), TRUE );
} }
} }
rect = icvCalcWindowRect(window); rect = icvCalcWindowRect(window);
MoveWindow(window->hwnd, rect.left, rect.top, MoveWindow(window->hwnd, rect.left, rect.top,
rect.right - rect.left + 1, rect.right - rect.left,
rect.bottom - rect.top + 1, TRUE ); rect.bottom - rect.top, TRUE );
} }
CV_IMPL void CV_IMPL void
@ -1331,18 +1331,18 @@ CV_IMPL void cvResizeWindow(const char* name, int width, int height )
{ {
rw = icvCalcWindowRect(window); rw = icvCalcWindowRect(window);
MoveWindow(window->hwnd, rw.left, rw.top, MoveWindow(window->hwnd, rw.left, rw.top,
rw.right - rw.left + 1, rw.bottom - rw.top + 1, FALSE); rw.right - rw.left, rw.bottom - rw.top, FALSE);
GetClientRect(window->hwnd, &rw); GetClientRect(window->hwnd, &rw);
GetWindowRect(window->frame, &rmw); GetWindowRect(window->frame, &rmw);
// Resize the mainhWnd window in order to make the bitmap fit into the child window // Resize the mainhWnd window in order to make the bitmap fit into the child window
MoveWindow(window->frame, rmw.left, rmw.top, MoveWindow(window->frame, rmw.left, rmw.top,
rmw.right - rmw.left + width - rw.right + rw.left, width + (rmw.right - rmw.left) - (rw.right - rw.left),
rmw.bottom - rmw.top + height - rw.bottom + rw.top, TRUE); height + (rmw.bottom - rmw.top) - (rw.bottom - rw.top), TRUE);
} }
rect = icvCalcWindowRect(window); rect = icvCalcWindowRect(window);
MoveWindow(window->hwnd, rect.left, rect.top, MoveWindow(window->hwnd, rect.left, rect.top,
rect.right - rect.left + 1, rect.bottom - rect.top + 1, TRUE); rect.right - rect.left, rect.bottom - rect.top, TRUE);
__END__; __END__;
} }
@ -1629,8 +1629,8 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
RECT rect = icvCalcWindowRect(window); RECT rect = icvCalcWindowRect(window);
pos->x = rect.left; pos->x = rect.left;
pos->y = rect.top; pos->y = rect.top;
pos->cx = rect.right - rect.left + 1; pos->cx = rect.right - rect.left;
pos->cy = rect.bottom - rect.top + 1; pos->cy = rect.bottom - rect.top;
} }
break; break;

Loading…
Cancel
Save