我有一张图片和一张旋转的图片来比较。
if (this.img.getHeight() == img1.getWidth() && this.img.getWidth() == img1.getHeight()) {
for (int i = 0; i < this.img.getWidth(); i++) {
for (int j = 0; j < this.img.getHeight(); j++) {
assertEquals(this.img.getRGB(i, j), img1.getRGB(this.img.getWidth() - j, i));
}
}
}
这是我使用的循环,但不知何故它不起作用。
图片顺时针旋转 90°。
this.img
是原图,img1
是旋转后的图。有人可以帮帮我吗?提前致谢!
您可能需要...
img1.getRGB(this.img1.getWidth() - j, i));
代替
img1.getRGB(this.img.getWidth() - j, i));
...因为您想从旋转图像的宽度向左移动,而不是原始图像的宽度(因为这将成为高度,因此不会出现在任何 x 轴计算中)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句