I'm trying to rotate to the left/or to the right an image ppm. I succeeded to rotate 180 degree but the 90 seems not working..
This is my code
// 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
}
So this is my results ..
http://i.stack.imgur.com/Cj6AM.png
http://i.stack.imgur.com/yTnbS.png
Someone have a solution to this ?
You flip your image dimensions after creating the new image. Try moving GaryImage *n_array = new GrayImage(o_width, o_height);
after switch (rotation) {...}
to use the correct height and width.
Edit: it should be GrayImage *n_array = new GrayImage(n_width, n_height);
anyway
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.