I have to write a function to rotate an image 90 degrees clockwise. I got it to rotate. But it also flipped and rotated counterclockwise. So wrong way, and it flipped along the y-axis. Really weird.
def rotate(self): rotatedImage = EmptyImage(self.height, self.width) for row in range(self.height): for col in range(self.width): (r, g, b) = self.image.getPixel2D(col, row) rotatedImage.setPixel2D(row, col, (r, g, b)) self.allImages.append(rotatedImage)
self.height and self.width are the height and width of the original image. self.image is the original image.
Can someone give me a pointer as to where I am messing up and a good direction to proceed?