我正试着向左/或向右旋转--一个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
有人有办法解决这个问题吗?
发布于 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);
https://stackoverflow.com/questions/22434438
复制相似问题