首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >旋转图像PPM

旋转图像PPM
EN

Stack Overflow用户
提问于 2014-03-16 07:58:37
回答 1查看 944关注 0票数 0

我正试着向左/或向右旋转--一个ppm的图像。我成功地旋转了180度,但90度似乎不起作用。

这是我的密码

代码语言:javascript
复制
// 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

有人有办法解决这个问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-16 08:06:44

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

编辑:反正应该是GrayImage *n_array = new GrayImage(n_width, n_height);

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22434438

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档