1

これは私がこれまでに持っているものです:

public static Photograph rotated(Photograph photo) {
    Photograph rotated_copy = new Photograph(photo.getHeight(), photo.getWidth());
    Pixel starting_pixel = photo.getPixel(0,0);

    for(int col = 0; col < photo.getWidth(); col++){
        for(int row = 0; row < photo.getHeight(); row++){
            starting_pixel = photo.getPixel(col,row);
            rotated_copy.setPixel(row, col, starting_pixel);
        }
    }
    return rotated_copy;
}

ただし、この方法では、撮影した写真は反時計回りに 90 度回転します。どうすればこれを修正できますか?

4

2 に答える 2

1
public static Photograph rotated(Photograph photo) {
    Photograph rotated_copy = new Photograph(photo.getHeight(), photo.getWidth());
    Pixel starting_pixel = photo.getPixel(0,0);

    for(int col = 0; col < photo.getWidth(); col++){
        for(int row = 0; row = photo.getHeight(); row++){
            starting_pixel = photo.getPixel(col,row);
            rotated_copy.setPixel(photo.getHeight() - row - 1, col, starting_pixel);
        }
    }
    return rotated_copy;
}

おもう。

于 2013-10-23T21:54:02.547 に答える