提交 5627a0cb 编写于 作者: X Xinguang Bian

fix scale problem in DefaultViewPort::controlImagePosition()

上级 9a9954a0
......@@ -2883,18 +2883,19 @@ inline bool DefaultViewPort::isSameSize(IplImage* img1, IplImage* img2)
void DefaultViewPort::controlImagePosition()
{
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
param_matrixWorld.map(0,0,&left,&top);
if (left > 0)
{
param_matrixWorld.translate(-left,0);
param_matrixWorld.translate(-left * factor, 0);
left = 0;
}
if (top > 0)
{
param_matrixWorld.translate(0,-top);
param_matrixWorld.translate(0, -top * factor);
top = 0;
}
//-------
......@@ -2903,12 +2904,12 @@ void DefaultViewPort::controlImagePosition()
param_matrixWorld.map(sizeImage.width(),sizeImage.height(),&right,&bottom);
if (right < sizeImage.width())
{
param_matrixWorld.translate(sizeImage.width()-right,0);
param_matrixWorld.translate((sizeImage.width() - right) * factor, 0);
right = sizeImage.width();
}
if (bottom < sizeImage.height())
{
param_matrixWorld.translate(0,sizeImage.height()-bottom);
param_matrixWorld.translate(0, (sizeImage.height() - bottom) * factor);
bottom = sizeImage.height();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册