0

画像 ppm を左/または右に回転させようとしています。180度回転には成功したのですが、90度回転がうまくいかないようです..

これは私のコードです

// working 1-D array of pixels pixel
*n_array = new Image(width, height);
// set up the new array dimensions based on ROTATION type
switch (the rotation)
{
    case ROTCW:
    case ROTCCW:
   ...
    break;

    case ROT180:
    default: .. break;
}

for (unsigned int idx = 0; idx < (o_width * o_height); idx++)
{
    old_y = idx / o_width;
    switch (rotation)
    {
        case ROTCCW: ... 
        default: cout << "Oups" << std::endl; break;
    }
    // put pixel into n_array
}

これが私の結果です..

http://i.stack.imgur.com/Cj6AM.png

http://i.stack.imgur.com/yTnbS.png

誰かがこれに対する解決策を持っていますか?

4

1 に答える 1

1

新しい画像を作成した後、画像の寸法を反転します。正しい高さと幅を使用するには、後で移動GaryImage *n_array = new GrayImage(o_width, o_height);し てみてください。switch (rotation) {...}

GrayImage *n_array = new GrayImage(n_width, n_height);編集:とにかくそうあるべきです

于 2014-03-16T08:06:44.717 に答える