I'm trying to get this code to run, but I keep getting an error saying:
at main.Main.flipVertically(Main.java:403) which is the code below.
img[row][col] = img[height - row - 1][col];
I don't know what's wrong with the code or the error they are talking about.
Here's the rest of the code:
public static int[][] flipVertically(int[][] img) {
String dir = "image.jpg";
img = Util.readImageToMatrix(dir);
int height = img[0].length;
int width = img.length;
for(int row = 0; row < height/2; row++)
{
for(int col = 0; col < width; col++)
{
int p = img[row][col];
img[row][col] = img[height - row - 1][col];
img[height - row - 1][col] = p;
}
}
return img;
}