Skip to content

Instantly share code, notes, and snippets.

@poemdexter
Last active March 7, 2016 16:07
Show Gist options
  • Save poemdexter/225a98fd94eaba07aa29 to your computer and use it in GitHub Desktop.
Save poemdexter/225a98fd94eaba07aa29 to your computer and use it in GitHub Desktop.
flipping pixels something something for ian
// oldArray newArray
// 0,1,2 6,7,8
// 3,4,5 --> 3,4,5
// 6,7,8 0,1,2
int x = width; // known size
int size = width * width; // always a square
int[] newArray = new int[size];
for (int i = 0; i < width; i++) {
for (int j = 0; j < width; j++) {
int oldArrayPos = size - width * (i + 1);
newArray[i * width + j] = oldArray[oldArrayPos + j];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment