0

I have a picture and a rotated picture to compare.

    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));
            }
        }
    }

This is the loop I use, but somehow it doesn't work.

The picture is rotated by 90° clockwise.

this.img is the original picture, img1 is the rotated picture. Can someone please help me? Thanks in advance!

derfium
  • 173
  • 1
  • 3
  • 15

1 Answers1

1

It is possible that you need...

img1.getRGB(this.img1.getWidth() - j, i));

instead of

img1.getRGB(this.img.getWidth() - j, i));

...since you want to go from the width of the rotated image to the left, instead of the width of the original image (since that would have become the height and thus would not appear on any x-axis calculation).

Florian Schaetz
  • 10,454
  • 5
  • 32
  • 58