提交 deb8ba22 编写于 作者: C Christoph Rackwitz 提交者: Maksim Shabunin

fix for #4990: highgui w32 ogl: correct calculation of image coordinates from window coordinates

上级 7d692890
......@@ -66,6 +66,7 @@
#include <functional>
#include "opencv2/highgui.hpp"
#include <GL/gl.h>
#include "opencv2/core/opengl.hpp"
#endif
static const char* trackbar_text =
......@@ -1489,7 +1490,20 @@ MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
GetClientRect( window->hwnd, &rect );
SIZE size = {0,0};
icvGetBitmapData( window, &size, 0, 0 );
#ifdef HAVE_OPENGL
if (window->useGl)
{
cv::ogl::Texture2D* texObj = static_cast<cv::ogl::Texture2D*>(window->glDrawData);
size.cx = texObj->cols();
size.cy = texObj->rows();
}
else
{
icvGetBitmapData(window, &size, 0, 0);
}
#else
icvGetBitmapData(window, &size, 0, 0);
#endif
window->on_mouse( event, pt.x*size.cx/MAX(rect.right - rect.left,1),
pt.y*size.cy/MAX(rect.bottom - rect.top,1), flags,
......@@ -1683,7 +1697,21 @@ static LRESULT CALLBACK HighGUIProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
SIZE size = {0, 0};
GetClientRect( window->hwnd, &rect );
#ifdef HAVE_OPENGL
if (window->useGl)
{
cv::ogl::Texture2D* texObj = static_cast<cv::ogl::Texture2D*>(window->glDrawData);
size.cx = texObj->cols();
size.cy = texObj->rows();
}
else
{
icvGetBitmapData(window, &size, 0, 0);
}
#else
icvGetBitmapData( window, &size, 0, 0 );
#endif
window->on_mouse( event, pt.x*size.cx/MAX(rect.right - rect.left,1),
pt.y*size.cy/MAX(rect.bottom - rect.top,1), flags,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册