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 回答