Merge pull request #20368 from mightbxg:bugfix_imshowqt

This commit is contained in:
Alexander Alekhin 2021-07-08 20:54:09 +00:00
commit 1ba6cd8423

View File

@ -2883,18 +2883,19 @@ inline bool DefaultViewPort::isSameSize(IplImage* img1, IplImage* img2)
void DefaultViewPort::controlImagePosition() void DefaultViewPort::controlImagePosition()
{ {
qreal left, top, right, bottom; qreal left, top, right, bottom;
qreal factor = 1.0 / param_matrixWorld.m11();
//after check top-left, bottom right corner to avoid getting "out" during zoom/panning //after check top-left, bottom right corner to avoid getting "out" during zoom/panning
param_matrixWorld.map(0,0,&left,&top); param_matrixWorld.map(0,0,&left,&top);
if (left > 0) if (left > 0)
{ {
param_matrixWorld.translate(-left,0); param_matrixWorld.translate(-left * factor, 0);
left = 0; left = 0;
} }
if (top > 0) if (top > 0)
{ {
param_matrixWorld.translate(0,-top); param_matrixWorld.translate(0, -top * factor);
top = 0; top = 0;
} }
//------- //-------
@ -2903,12 +2904,12 @@ void DefaultViewPort::controlImagePosition()
param_matrixWorld.map(sizeImage.width(),sizeImage.height(),&right,&bottom); param_matrixWorld.map(sizeImage.width(),sizeImage.height(),&right,&bottom);
if (right < sizeImage.width()) if (right < sizeImage.width())
{ {
param_matrixWorld.translate(sizeImage.width()-right,0); param_matrixWorld.translate((sizeImage.width() - right) * factor, 0);
right = sizeImage.width(); right = sizeImage.width();
} }
if (bottom < sizeImage.height()) if (bottom < sizeImage.height())
{ {
param_matrixWorld.translate(0,sizeImage.height()-bottom); param_matrixWorld.translate(0, (sizeImage.height() - bottom) * factor);
bottom = sizeImage.height(); bottom = sizeImage.height();
} }