I have this as a color array:
public RGBImage(int width, int height, RGBColor background) {
pixel = new RGBColor[width][height];
this.w = width;
this.h = height;
this.b = background;
for(x = 0; x < width; x++){
for(y = 0; y < height; y++){
pixel[x][y] = b;
}
}
and i want to rotate it, right, the code is already doing good regarding square matrix thanks to @Oblivion Creations, but I'm getting outofbounds errors when using it non squared matrixes
public void rotateRight() {
RGBColor[][] mirror = new RGBColor[h][w];
for(int i = 0 ; i < h; i++){
for(int j = 0 ; j < w; j++){
mirror[i][j] = pixel[j][w-i-1];
}
}
pixel = mirror;
}