【问题标题】:rotate an image PPM旋转图像 PPM
【发布时间】:2014-03-16 07:58:37
【问题描述】:

我正在尝试向左/向右旋转图像 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

有人可以解决这个问题吗?

【问题讨论】:

    标签: c++ rotation ppm


    【解决方案1】:

    您在创建新图像后翻转图像尺寸。 尝试在switch (rotation) {...} 之后移动GaryImage *n_array = new GrayImage(o_width, o_height); 以使用正确的高度和宽度。

    编辑:无论如何都应该是GrayImage *n_array = new GrayImage(n_width, n_height);

    【讨论】:

    • 是的! Sankyu @Eric E. Lorenz
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多