Rotate an image that is in an array

0

Good afternoon, I have a color image in a 1D array, for example:

int[] image = {255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 255, 0, 255, 0, 255, 0, 0};

This array has 6 pixels, red, green, blue, blue, green, red, imagining that these pixels are positioned horizontally:

| Vermelho | Verde | Azul     |
| Azul     | Verde | Vermelho |

In what way I could rotate this image so that the pixel layout becomes vertical:

| Azul     | Vermelho |
| Verde    | Verde    |
| Vermelho | Azul     |

I want to put this rotated array in another 1D array.

    
asked by anonymous 18.03.2017 / 22:45

1 answer

1

If you are working with the one-dimensional array, then there is no such concept as horizontal or vertical. What you can do is replace the position of the colors.

But if you want to turn the array into a two-dimensional array, then I suggest reading the answers to these two questions that will help you a lot:

You can rotate colors into a two-dimensional array and then convert back to a one-dimensional array.

    
18.03.2017 / 23:02