我的计算似乎是移动图像而不是缩放图像。不太确定我哪里出错了。我以为我在这里正确地跟着另一篇文章,但这不太对。
int xPos = ev.xbutton.x;
int yPos = ev.xbutton.y;
double xCenter = (double) ((double) ((double) xPos / X_RESN) * (rmax - rmin)) + rmin;
double yCenter = (double) ((double) ((double) yPos / Y_RESN) * (imax - imin)) + imin;
double pixelFactors[4];
if(ev.xbutton.button == 1) //Left click, zoom in
{
rmin = (double) xCenter + (rmin + 0.3);
rmax = (double) xCenter + (rmax - 0.3);
imin = (double) yCenter + (imin + 0.3);
imax = (double) yCenter + (imax - 0.3);
}
else if(ev.xbutton.button == 3) //Right click, zoom out
{
rmin = -2;
rmax = 2;
imin = -2;
imax = 2;
}
答案 0 :(得分:1)
您写道:
rmin = (double) xCenter + (rmin + 0.3);
rmax = (double) xCenter + (rmax - 0.3);
imin = (double) yCenter + (imin + 0.3);
imax = (double) yCenter + (imax - 0.3);
那里不应该有一些乘法吗?也许更像是:
rmin = (double) xCenter + (rmin * 0.3);
rmax = (double) xCenter + (rmax * 0.3);
imin = (double) yCenter + (imin * 0.3);
imax = (double) yCenter + (imax * 0.3);
如果您只想让分钟和最大值更接近,xCenter和yCenter在复平面坐标中定义图像的中间(即不是像素坐标),我想这可能是更接近你想要的。
double rspan = rmax - rmin;
double ispan = imax - imin;
rmin = xCenter - (rspan * 0.3);
rmax = xCenter + (rspan * 0.3);
imin = yCenter - (rspan * 0.3);
imax = yCenter + (rspan * 0.3);
请注意,不再需要演员表。