我有这个作为颜色数组:
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;
}
}
我想旋转它,对,由于@Oblivion Creations ,代码在方阵方面已经做得很好了,但是在使用非方阵时 我遇到了越界错误
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;
}