Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaSWT:从缩放图像获取原始X/Y坐标_Java_Image_Image Processing_Swt - Fatal编程技术网

JavaSWT:从缩放图像获取原始X/Y坐标

JavaSWT:从缩放图像获取原始X/Y坐标,java,image,image-processing,swt,Java,Image,Image Processing,Swt,我有一个图像在哪里 Height = 1300 Width = 1300 我将图像缩放为: 标度高度=700 标度宽度=700 我使用以下方法获取原始坐标: public Coordinate GetScaledXYCoordinate(int oldX, int oldY, int width, int height, int scaledWidth, int scaledHeight) { int newX = (int)(oldX * width)/scaledWi

我有一个图像在哪里

Height = 1300
Width = 1300
我将图像缩放为: 标度高度=700 标度宽度=700

我使用以下方法获取原始坐标:

public Coordinate GetScaledXYCoordinate(int oldX, int oldY, int width, int height, int scaledWidth, int scaledHeight)
{       
    int newX = (int)(oldX * width)/scaledWidth;
    int newY = (int)(oldY * height)/scaledHeight;

    Coordinate retXY = new Coordinate(newX, newY);
    return retXY;
}
编辑: 我已更新,将答案包含在

int width = 1300;
int scaledWidth = 700;
(width/scaledWidth)
的值为1-您正在执行的是整数算术而不是浮点运算

使用

以避免此问题。

使用

int width = 1300;
int scaledWidth = 700;
(width/scaledWidth)
的值为1-您正在执行的是整数算术而不是浮点运算

使用


为避免此问题。

您可以添加示例输入和方法的相应输出吗?您可以添加示例输入和方法的相应输出吗?谢谢@greg-449的帮助谢谢@greg-449的帮助