Backport some highgui changes from #22754

pull/25160/head
Alexander Smorkalov 9 months ago
parent b34ec57682
commit f2c38eb62f
  1. 18
      modules/highgui/src/window.cpp
  2. 22
      modules/highgui/src/window_QT.cpp
  3. 50
      modules/highgui/src/window_gtk.cpp
  4. 34
      modules/highgui/src/window_w32.cpp
  5. 6
      modules/highgui/src/window_wayland.cpp

@ -217,9 +217,9 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
switch(prop_id) switch(prop_id)
{ {
//change between fullscreen or not. //change between fullscreen or not.
case CV_WND_PROP_FULLSCREEN: case cv::WND_PROP_FULLSCREEN:
if (prop_value != CV_WINDOW_NORMAL && prop_value != CV_WINDOW_FULLSCREEN) // bad argument if (prop_value != cv::WINDOW_NORMAL && prop_value != cv::WINDOW_FULLSCREEN) // bad argument
break; break;
#if defined (HAVE_QT) #if defined (HAVE_QT)
@ -236,13 +236,13 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu
break; break;
case CV_WND_PROP_AUTOSIZE: case cv::WND_PROP_AUTOSIZE:
#if defined (HAVE_QT) #if defined (HAVE_QT)
cvSetPropWindow_QT(name,prop_value); cvSetPropWindow_QT(name,prop_value);
#endif #endif
break; break;
case CV_WND_PROP_ASPECTRATIO: case cv::WND_PROP_ASPECT_RATIO:
#if defined (HAVE_QT) #if defined (HAVE_QT)
cvSetRatioWindow_QT(name,prop_value); cvSetRatioWindow_QT(name,prop_value);
#endif #endif
@ -305,7 +305,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#else #else
switch(prop_id) switch(prop_id)
{ {
case CV_WND_PROP_FULLSCREEN: case cv::WND_PROP_FULLSCREEN:
#if defined (HAVE_QT) #if defined (HAVE_QT)
return cvGetModeWindow_QT(name); return cvGetModeWindow_QT(name);
@ -322,7 +322,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#endif #endif
break; break;
case CV_WND_PROP_AUTOSIZE: case cv::WND_PROP_AUTOSIZE:
#if defined (HAVE_QT) #if defined (HAVE_QT)
return cvGetPropWindow_QT(name); return cvGetPropWindow_QT(name);
@ -335,7 +335,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#endif #endif
break; break;
case CV_WND_PROP_ASPECTRATIO: case cv::WND_PROP_ASPECT_RATIO:
#if defined (HAVE_QT) #if defined (HAVE_QT)
return cvGetRatioWindow_QT(name); return cvGetRatioWindow_QT(name);
@ -348,7 +348,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#endif #endif
break; break;
case CV_WND_PROP_OPENGL: case cv::WND_PROP_OPENGL:
#if defined (HAVE_QT) #if defined (HAVE_QT)
return cvGetOpenGlProp_QT(name); return cvGetOpenGlProp_QT(name);
@ -361,7 +361,7 @@ CV_IMPL double cvGetWindowProperty(const char* name, int prop_id)
#endif #endif
break; break;
case CV_WND_PROP_VISIBLE: case cv::WND_PROP_VISIBLE:
#if defined (HAVE_QT) #if defined (HAVE_QT)
return cvGetPropVisible_QT(name); return cvGetPropVisible_QT(name);
#elif defined(HAVE_WIN32UI) #elif defined(HAVE_WIN32UI)

@ -1016,7 +1016,7 @@ double GuiReceiver::isFullScreen(QString name)
if (!w) if (!w)
return -1; return -1;
return w->isFullScreen() ? CV_WINDOW_FULLSCREEN : CV_WINDOW_NORMAL; return w->isFullScreen() ? cv::WINDOW_FULLSCREEN : cv::WINDOW_NORMAL;
} }
@ -1702,11 +1702,11 @@ CvWindow::CvWindow(QString name, int arg2)
//3: my view //3: my view
#ifndef HAVE_QT_OPENGL #ifndef HAVE_QT_OPENGL
if (arg2 & CV_WINDOW_OPENGL) if (arg2 & cv::WINDOW_OPENGL)
CV_Error( cv::Error::OpenGlNotSupported, "Library was built without OpenGL support" ); CV_Error( cv::Error::OpenGlNotSupported, "Library was built without OpenGL support" );
mode_display = CV_MODE_NORMAL; mode_display = CV_MODE_NORMAL;
#else #else
mode_display = arg2 & CV_WINDOW_OPENGL ? CV_MODE_OPENGL : CV_MODE_NORMAL; mode_display = arg2 & cv::WINDOW_OPENGL ? CV_MODE_OPENGL : CV_MODE_NORMAL;
if (mode_display == CV_MODE_OPENGL) if (mode_display == CV_MODE_OPENGL)
param_gui_mode = CV_GUI_NORMAL; param_gui_mode = CV_GUI_NORMAL;
#endif #endif
@ -1837,13 +1837,13 @@ void CvWindow::setPropWindow(int flags)
switch(flags) switch(flags)
{ {
case CV_WINDOW_NORMAL: case cv::WINDOW_NORMAL:
myGlobalLayout->setSizeConstraint(QLayout::SetMinAndMaxSize); myGlobalLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
param_flags = flags; param_flags = flags;
break; break;
case CV_WINDOW_AUTOSIZE: case cv::WINDOW_AUTOSIZE:
myGlobalLayout->setSizeConstraint(QLayout::SetFixedSize); myGlobalLayout->setSizeConstraint(QLayout::SetFixedSize);
param_flags = flags; param_flags = flags;
@ -1856,14 +1856,14 @@ void CvWindow::setPropWindow(int flags)
void CvWindow::toggleFullScreen(int flags) void CvWindow::toggleFullScreen(int flags)
{ {
if (isFullScreen() && flags == CV_WINDOW_NORMAL) if (isFullScreen() && flags == cv::WINDOW_NORMAL)
{ {
showTools(); showTools();
showNormal(); showNormal();
return; return;
} }
if (!isFullScreen() && flags == CV_WINDOW_FULLSCREEN) if (!isFullScreen() && flags == cv::WINDOW_FULLSCREEN)
{ {
hideTools(); hideTools();
showFullScreen(); showFullScreen();
@ -2013,9 +2013,9 @@ void CvWindow::createGlobalLayout()
#endif #endif
setMinimumSize(1, 1); setMinimumSize(1, 1);
if (param_flags == CV_WINDOW_AUTOSIZE) if (param_flags == cv::WINDOW_AUTOSIZE)
myGlobalLayout->setSizeConstraint(QLayout::SetFixedSize); myGlobalLayout->setSizeConstraint(QLayout::SetFixedSize);
else if (param_flags == CV_WINDOW_NORMAL) else if (param_flags == cv::WINDOW_NORMAL)
myGlobalLayout->setSizeConstraint(QLayout::SetMinAndMaxSize); myGlobalLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
} }
@ -2605,7 +2605,7 @@ void DefaultViewPort::setRatio(int flags)
return; return;
//if valid flags //if valid flags
if (flags == CV_WINDOW_FREERATIO || flags == CV_WINDOW_KEEPRATIO) if (flags == cv::WINDOW_FREERATIO || flags == cv::WINDOW_KEEPRATIO)
{ {
centralWidget->param_ratio_mode = flags; centralWidget->param_ratio_mode = flags;
param_keepRatio = flags; param_keepRatio = flags;
@ -2816,7 +2816,7 @@ void DefaultViewPort::resizeEvent(QResizeEvent* evnt)
ratioX = width() / float(image2Draw_mat->cols); ratioX = width() / float(image2Draw_mat->cols);
ratioY = height() / float(image2Draw_mat->rows); ratioY = height() / float(image2Draw_mat->rows);
if (param_keepRatio == CV_WINDOW_KEEPRATIO)//to keep the same aspect ratio if (param_keepRatio == cv::WINDOW_KEEPRATIO)//to keep the same aspect ratio
{ {
QSize newSize = QSize(image2Draw_mat->cols, image2Draw_mat->rows); QSize newSize = QSize(image2Draw_mat->cols, image2Draw_mat->rows);
newSize.scale(evnt->size(), Qt::KeepAspectRatio); newSize.scale(evnt->size(), Qt::KeepAspectRatio);

@ -271,7 +271,7 @@ cvImageWidget_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget ); CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
if(image_widget->original_image != NULL) { if(image_widget->original_image != NULL) {
*minimal_width = (image_widget->flags & CV_WINDOW_AUTOSIZE) != CV_WINDOW_AUTOSIZE ? *minimal_width = (image_widget->flags & cv::WINDOW_AUTOSIZE) != cv::WINDOW_AUTOSIZE ?
gdk_window_get_width(gtk_widget_get_window(widget)) : image_widget->original_image->cols; gdk_window_get_width(gtk_widget_get_window(widget)) : image_widget->original_image->cols;
} }
else { else {
@ -295,7 +295,7 @@ cvImageWidget_get_preferred_height (GtkWidget *widget, gint *minimal_height, gin
CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget ); CvImageWidget * image_widget = CV_IMAGE_WIDGET( widget );
if(image_widget->original_image != NULL) { if(image_widget->original_image != NULL) {
*minimal_height = (image_widget->flags & CV_WINDOW_AUTOSIZE) != CV_WINDOW_AUTOSIZE ? *minimal_height = (image_widget->flags & cv::WINDOW_AUTOSIZE) != cv::WINDOW_AUTOSIZE ?
gdk_window_get_height(gtk_widget_get_window(widget)) : image_widget->original_image->rows; gdk_window_get_height(gtk_widget_get_window(widget)) : image_widget->original_image->rows;
} }
else { else {
@ -322,7 +322,7 @@ cvImageWidget_size_request (GtkWidget *widget,
//printf("cvImageWidget_size_request "); //printf("cvImageWidget_size_request ");
// the case the first time cvShowImage called or when AUTOSIZE // the case the first time cvShowImage called or when AUTOSIZE
if( image_widget->original_image && if( image_widget->original_image &&
((image_widget->flags & CV_WINDOW_AUTOSIZE) || ((image_widget->flags & cv::WINDOW_AUTOSIZE) ||
(image_widget->flags & CV_WINDOW_NO_IMAGE))) (image_widget->flags & CV_WINDOW_NO_IMAGE)))
{ {
//printf("original "); //printf("original ");
@ -351,7 +351,7 @@ static void cvImageWidget_set_size(GtkWidget * widget, int max_width, int max_he
//printf("cvImageWidget_set_size %d %d\n", max_width, max_height); //printf("cvImageWidget_set_size %d %d\n", max_width, max_height);
// don't allow to set the size // don't allow to set the size
if(image_widget->flags & CV_WINDOW_AUTOSIZE) return; if(image_widget->flags & cv::WINDOW_AUTOSIZE) return;
if(!image_widget->original_image) return; if(!image_widget->original_image) return;
CvSize scaled_image_size = cvImageWidget_calc_size( image_widget->original_image->cols, CvSize scaled_image_size = cvImageWidget_calc_size( image_widget->original_image->cols,
@ -390,7 +390,7 @@ cvImageWidget_size_allocate (GtkWidget *widget,
image_widget = CV_IMAGE_WIDGET (widget); image_widget = CV_IMAGE_WIDGET (widget);
if( (image_widget->flags & CV_WINDOW_AUTOSIZE)==0 && image_widget->original_image ){ if( (image_widget->flags & cv::WINDOW_AUTOSIZE)==0 && image_widget->original_image ){
// (re) allocated scaled image // (re) allocated scaled image
if( image_widget->flags & CV_WINDOW_NO_IMAGE ){ if( image_widget->flags & CV_WINDOW_NO_IMAGE ){
cvImageWidget_set_size( widget, image_widget->original_image->cols, cvImageWidget_set_size( widget, image_widget->original_image->cols,
@ -407,7 +407,7 @@ cvImageWidget_size_allocate (GtkWidget *widget,
image_widget = CV_IMAGE_WIDGET (widget); image_widget = CV_IMAGE_WIDGET (widget);
if( image_widget->original_image && if( image_widget->original_image &&
((image_widget->flags & CV_WINDOW_AUTOSIZE) || ((image_widget->flags & cv::WINDOW_AUTOSIZE) ||
(image_widget->flags & CV_WINDOW_NO_IMAGE)) ) (image_widget->flags & CV_WINDOW_NO_IMAGE)) )
{ {
#if defined (GTK_VERSION3) #if defined (GTK_VERSION3)
@ -808,7 +808,7 @@ void cvSetModeWindow_GTK( const char* name, double prop_value)//Yannick Verdie
static bool setModeWindow_(const std::shared_ptr<CvWindow>& window, int mode) static bool setModeWindow_(const std::shared_ptr<CvWindow>& window, int mode)
{ {
if (window->flags & CV_WINDOW_AUTOSIZE) //if the flag CV_WINDOW_AUTOSIZE is set if (window->flags & cv::WINDOW_AUTOSIZE) //if the flag cv::WINDOW_AUTOSIZE is set
return false; return false;
//so easy to do fullscreen here, Linux rocks ! //so easy to do fullscreen here, Linux rocks !
@ -816,17 +816,17 @@ static bool setModeWindow_(const std::shared_ptr<CvWindow>& window, int mode)
if (window->status == mode) if (window->status == mode)
return true; return true;
if (window->status==CV_WINDOW_FULLSCREEN && mode==CV_WINDOW_NORMAL) if (window->status==cv::WINDOW_FULLSCREEN && mode==cv::WINDOW_NORMAL)
{ {
gtk_window_unfullscreen(GTK_WINDOW(window->frame)); gtk_window_unfullscreen(GTK_WINDOW(window->frame));
window->status=CV_WINDOW_NORMAL; window->status=cv::WINDOW_NORMAL;
return true; return true;
} }
if (window->status==CV_WINDOW_NORMAL && mode==CV_WINDOW_FULLSCREEN) if (window->status==cv::WINDOW_NORMAL && mode==cv::WINDOW_FULLSCREEN)
{ {
gtk_window_fullscreen(GTK_WINDOW(window->frame)); gtk_window_fullscreen(GTK_WINDOW(window->frame));
window->status=CV_WINDOW_FULLSCREEN; window->status=cv::WINDOW_FULLSCREEN;
return true; return true;
} }
@ -859,7 +859,7 @@ double cvGetPropWindowAutoSize_GTK(const char* name)
if (!window) if (!window)
return -1; // keep silence here return -1; // keep silence here
double result = window->flags & CV_WINDOW_AUTOSIZE; double result = window->flags & cv::WINDOW_AUTOSIZE;
return result; return result;
} }
@ -1037,7 +1037,7 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
auto window_ptr = std::make_shared<CvWindow>(name); auto window_ptr = std::make_shared<CvWindow>(name);
CvWindow* window = window_ptr.get(); CvWindow* window = window_ptr.get();
window->flags = flags; window->flags = flags;
window->status = CV_WINDOW_NORMAL;//YV window->status = cv::WINDOW_NORMAL;//YV
window->frame = gtk_window_new( GTK_WINDOW_TOPLEVEL ); window->frame = gtk_window_new( GTK_WINDOW_TOPLEVEL );
@ -1049,10 +1049,10 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
gtk_widget_show( window->paned ); gtk_widget_show( window->paned );
#ifndef HAVE_OPENGL #ifndef HAVE_OPENGL
if (flags & CV_WINDOW_OPENGL) if (flags & cv::WINDOW_OPENGL)
CV_Error( cv::Error::OpenGlNotSupported, "Library was built without OpenGL support" ); CV_Error( cv::Error::OpenGlNotSupported, "Library was built without OpenGL support" );
#else #else
if (flags & CV_WINDOW_OPENGL) if (flags & cv::WINDOW_OPENGL)
createGlContext(window); createGlContext(window);
window->glDrawCallback = 0; window->glDrawCallback = 0;
@ -1097,7 +1097,7 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
getGTKWindows().push_back(window_ptr); getGTKWindows().push_back(window_ptr);
} }
bool b_nautosize = ((flags & CV_WINDOW_AUTOSIZE) == 0); bool b_nautosize = ((flags & cv::WINDOW_AUTOSIZE) == 0);
gtk_window_set_resizable( GTK_WINDOW(window->frame), b_nautosize ); gtk_window_set_resizable( GTK_WINDOW(window->frame), b_nautosize );
// allow window to be resized // allow window to be resized
@ -1333,7 +1333,7 @@ void resizeWindow_(const std::shared_ptr<CvWindow>& window, int width, int heigh
{ {
CV_Assert(window); CV_Assert(window);
CvImageWidget* image_widget = CV_IMAGE_WIDGET( window->widget ); CvImageWidget* image_widget = CV_IMAGE_WIDGET( window->widget );
//if(image_widget->flags & CV_WINDOW_AUTOSIZE) //if(image_widget->flags & cv::WINDOW_AUTOSIZE)
//EXIT; //EXIT;
gtk_window_set_resizable( GTK_WINDOW(window->frame), 1 ); gtk_window_set_resizable( GTK_WINDOW(window->frame), 1 );
@ -1916,7 +1916,7 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
if( cv_event >= 0 ) if( cv_event >= 0 )
{ {
// scale point if image is scaled // scale point if image is scaled
if( (image_widget->flags & CV_WINDOW_AUTOSIZE)==0 && if( (image_widget->flags & cv::WINDOW_AUTOSIZE)==0 &&
image_widget->original_image && image_widget->original_image &&
image_widget->scaled_image ) image_widget->scaled_image )
{ {
@ -2080,17 +2080,17 @@ public:
// see cvGetWindowProperty // see cvGetWindowProperty
switch (prop) switch (prop)
{ {
case CV_WND_PROP_FULLSCREEN: case cv::WND_PROP_FULLSCREEN:
return (double)window->status; return (double)window->status;
case CV_WND_PROP_AUTOSIZE: case cv::WND_PROP_AUTOSIZE:
return (window->flags & CV_WINDOW_AUTOSIZE) ? 1.0 : 0.0; return (window->flags & cv::WINDOW_AUTOSIZE) ? 1.0 : 0.0;
case CV_WND_PROP_ASPECTRATIO: case cv::WND_PROP_ASPECT_RATIO:
return getRatioWindow_(window); return getRatioWindow_(window);
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
case CV_WND_PROP_OPENGL: case cv::WND_PROP_OPENGL:
return window->useGl ? 1.0 : 0.0; return window->useGl ? 1.0 : 0.0;
#endif #endif
@ -2107,8 +2107,8 @@ public:
// see cvSetWindowProperty // see cvSetWindowProperty
switch (prop) switch (prop)
{ {
case CV_WND_PROP_FULLSCREEN: case cv::WND_PROP_FULLSCREEN:
if (value != CV_WINDOW_NORMAL && value != CV_WINDOW_FULLSCREEN) // bad arg if (value != cv::WINDOW_NORMAL && value != cv::WINDOW_FULLSCREEN) // bad arg
break; break;
setModeWindow_(window, value); setModeWindow_(window, value);
return true; return true;

@ -587,7 +587,7 @@ void cvSetModeWindow_W32(const char* name, double prop_value)//Yannick Verdie
static bool setModeWindow_(CvWindow& window, int mode) static bool setModeWindow_(CvWindow& window, int mode)
{ {
if (window.flags & CV_WINDOW_AUTOSIZE)//if the flag CV_WINDOW_AUTOSIZE is set if (window.flags & cv::WINDOW_AUTOSIZE)//if the flag cv::WINDOW_AUTOSIZE is set
return false; return false;
if (window.status == mode) if (window.status == mode)
@ -597,18 +597,18 @@ static bool setModeWindow_(CvWindow& window, int mode)
DWORD dwStyle = (DWORD)GetWindowLongPtr(window.frame, GWL_STYLE); DWORD dwStyle = (DWORD)GetWindowLongPtr(window.frame, GWL_STYLE);
CvRect position; CvRect position;
if (window.status == CV_WINDOW_FULLSCREEN && mode == CV_WINDOW_NORMAL) if (window.status == cv::WINDOW_FULLSCREEN && mode == cv::WINDOW_NORMAL)
{ {
icvLoadWindowPos(window.name.c_str(), position); icvLoadWindowPos(window.name.c_str(), position);
SetWindowLongPtr(window.frame, GWL_STYLE, dwStyle | WS_CAPTION | WS_THICKFRAME); SetWindowLongPtr(window.frame, GWL_STYLE, dwStyle | WS_CAPTION | WS_THICKFRAME);
SetWindowPos(window.frame, HWND_TOP, position.x, position.y , position.width,position.height, SWP_NOZORDER | SWP_FRAMECHANGED); SetWindowPos(window.frame, HWND_TOP, position.x, position.y , position.width,position.height, SWP_NOZORDER | SWP_FRAMECHANGED);
window.status=CV_WINDOW_NORMAL; window.status=cv::WINDOW_NORMAL;
return true; return true;
} }
if (window.status == CV_WINDOW_NORMAL && mode == CV_WINDOW_FULLSCREEN) if (window.status == cv::WINDOW_NORMAL && mode == cv::WINDOW_FULLSCREEN)
{ {
//save dimension //save dimension
RECT rect = { 0 }; RECT rect = { 0 };
@ -630,7 +630,7 @@ static bool setModeWindow_(CvWindow& window, int mode)
SetWindowLongPtr(window.frame, GWL_STYLE, dwStyle & ~WS_CAPTION & ~WS_THICKFRAME); SetWindowLongPtr(window.frame, GWL_STYLE, dwStyle & ~WS_CAPTION & ~WS_THICKFRAME);
SetWindowPos(window.frame, HWND_TOP, position.x, position.y , position.width,position.height, SWP_NOZORDER | SWP_FRAMECHANGED); SetWindowPos(window.frame, HWND_TOP, position.x, position.y , position.width,position.height, SWP_NOZORDER | SWP_FRAMECHANGED);
window.status=CV_WINDOW_FULLSCREEN; window.status=cv::WINDOW_FULLSCREEN;
return true; return true;
} }
@ -836,7 +836,7 @@ double cvGetPropWindowAutoSize_W32(const char* name)
if (!window) if (!window)
CV_Error_(Error::StsNullPtr, ("NULL window: '%s'", name)); CV_Error_(Error::StsNullPtr, ("NULL window: '%s'", name));
result = window->flags & CV_WINDOW_AUTOSIZE; result = window->flags & cv::WINDOW_AUTOSIZE;
return result; return result;
} }
@ -1055,11 +1055,11 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
CvRect rect; CvRect rect;
icvLoadWindowPos(name.c_str(), rect); icvLoadWindowPos(name.c_str(), rect);
if (!(flags & CV_WINDOW_AUTOSIZE))//YV add border in order to resize the window if (!(flags & cv::WINDOW_AUTOSIZE))//YV add border in order to resize the window
defStyle |= WS_SIZEBOX; defStyle |= WS_SIZEBOX;
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
if (flags & CV_WINDOW_OPENGL) if (flags & cv::WINDOW_OPENGL)
defStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; defStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
#endif #endif
@ -1076,14 +1076,14 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
CV_Error(Error::StsError, "Frame window can not be created"); CV_Error(Error::StsError, "Frame window can not be created");
#ifndef HAVE_OPENGL #ifndef HAVE_OPENGL
if (flags & CV_WINDOW_OPENGL) if (flags & cv::WINDOW_OPENGL)
CV_Error(Error::OpenGlNotSupported, "Library was built without OpenGL support"); CV_Error(Error::OpenGlNotSupported, "Library was built without OpenGL support");
#else #else
useGl = false; useGl = false;
hGLDC = 0; hGLDC = 0;
hGLRC = 0; hGLRC = 0;
if (flags & CV_WINDOW_OPENGL) if (flags & cv::WINDOW_OPENGL)
createGlContext(hWnd, hGLDC, hGLRC, useGl); createGlContext(hWnd, hGLDC, hGLRC, useGl);
#endif #endif
@ -1117,7 +1117,7 @@ static std::shared_ptr<CvWindow> namedWindow_(const std::string& name, int flags
#endif #endif
window->last_key = 0; window->last_key = 0;
window->status = CV_WINDOW_NORMAL;//YV window->status = cv::WINDOW_NORMAL;//YV
window->on_mouse = 0; window->on_mouse = 0;
window->on_mouse_param = 0; window->on_mouse_param = 0;
@ -1338,7 +1338,7 @@ static void icvUpdateWindowPos(CvWindow& window)
{ {
RECT rect = { 0 }; RECT rect = { 0 };
if ((window.flags & CV_WINDOW_AUTOSIZE) && window.image) if ((window.flags & cv::WINDOW_AUTOSIZE) && window.image)
{ {
int i; int i;
SIZE size = {0,0}; SIZE size = {0,0};
@ -1383,7 +1383,7 @@ cvShowImage(const char* name, const CvArr* arr)
window = icvFindWindowByName(name); window = icvFindWindowByName(name);
if (!window) if (!window)
{ {
cvNamedWindow(name, CV_WINDOW_AUTOSIZE); cvNamedWindow(name, cv::WINDOW_AUTOSIZE);
window = icvFindWindowByName(name); window = icvFindWindowByName(name);
} }
} }
@ -1548,7 +1548,7 @@ MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
break; break;
case WM_GETMINMAXINFO: case WM_GETMINMAXINFO:
if (!(window.flags & CV_WINDOW_AUTOSIZE)) if (!(window.flags & cv::WINDOW_AUTOSIZE))
{ {
MINMAXINFO* minmax = (MINMAXINFO*)lParam; MINMAXINFO* minmax = (MINMAXINFO*)lParam;
RECT rect = { 0 }; RECT rect = { 0 };
@ -1579,7 +1579,7 @@ MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
MoveWindow(window.toolbar.toolbar, 0, 0, pos->cx, rect.bottom - rect.top, TRUE); MoveWindow(window.toolbar.toolbar, 0, 0, pos->cx, rect.bottom - rect.top, TRUE);
} }
if (!(window.flags & CV_WINDOW_AUTOSIZE)) if (!(window.flags & cv::WINDOW_AUTOSIZE))
icvUpdateWindowPos(window); icvUpdateWindowPos(window);
break; break;
@ -1846,7 +1846,7 @@ static LRESULT CALLBACK HighGUIProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
pt.x = GET_X_LPARAM(lParam); pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam);
if (window.flags & CV_WINDOW_AUTOSIZE) if (window.flags & cv::WINDOW_AUTOSIZE)
{ {
// As user can't change window size, do not scale window coordinates. Underlying windowing system // As user can't change window size, do not scale window coordinates. Underlying windowing system
// may prevent full window from being displayed and in this case coordinates should not be scaled. // may prevent full window from being displayed and in this case coordinates should not be scaled.
@ -1908,7 +1908,7 @@ static LRESULT CALLBACK HighGUIProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
SetDIBColorTable(window.dc, 0, 255, table); SetDIBColorTable(window.dc, 0, 255, table);
} }
if (window.flags & CV_WINDOW_AUTOSIZE) if (window.flags & cv::WINDOW_AUTOSIZE)
{ {
BitBlt(hdc, 0, 0, size.cx, size.cy, window.dc, 0, 0, SRCCOPY); BitBlt(hdc, 0, 0, size.cx, size.cy, window.dc, 0, 0, SRCCOPY);
} }

@ -1509,7 +1509,7 @@ void cv_wl_viewer::get_preferred_height_for_width(int width, int &minimum, int &
minimum = natural = image_.size().height; minimum = natural = image_.size().height;
} else { } else {
natural = static_cast<int>(width * aspect_ratio(image_.size())); natural = static_cast<int>(width * aspect_ratio(image_.size()));
minimum = (flags_ & CV_WINDOW_FREERATIO ? 0 : natural); minimum = (flags_ & cv::WINDOW_FREERATIO ? 0 : natural);
} }
} }
@ -1548,11 +1548,11 @@ cv::Rect cv_wl_viewer::draw(void *data, cv::Size const &size, bool force) {
CV_Assert(image_.size() == size); CV_Assert(image_.size() == size);
write_mat_to_xrgb8888(image_, data); write_mat_to_xrgb8888(image_, data);
} else { } else {
if (flags_ & CV_WINDOW_FREERATIO) { if (flags_ & cv::WINDOW_FREERATIO) {
cv::Mat resized; cv::Mat resized;
cv::resize(image_, resized, size); cv::resize(image_, resized, size);
write_mat_to_xrgb8888(resized, data); write_mat_to_xrgb8888(resized, data);
} else /* CV_WINDOW_KEEPRATIO */ { } else /* cv::WINDOW_KEEPRATIO */ {
auto rect = cv::Rect(cv::Point(0, 0), size); auto rect = cv::Rect(cv::Point(0, 0), size);
if (aspect_ratio(size) >= aspect_ratio(image_.size())) { if (aspect_ratio(size) >= aspect_ratio(image_.size())) {
rect.height = static_cast<int>(image_.size().height * ((double) rect.width / image_.size().width)); rect.height = static_cast<int>(image_.size().height * ((double) rect.width / image_.size().width));

Loading…
Cancel
Save