Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void rotate() {
- long startTime = System.nanoTime();
- newPixels = new int[width * height];
- for (int x = 0; x < width; x++) {
- int offset = x * height;
- for (int y = 0; y < height; y++) {
- newPixels[offset + y] = pixels[y * width + x];
- }
- }
- for (int x = 0; x < width; x++) {
- int offset = x * height;
- for (int y = 0; y < height; y++) {
- pixels[offset + y] = newPixels[offset + height - 1 - y];
- }
- }
- int tmp = width;
- width = height;
- height = tmp;
- long finishTime = System.nanoTime();
- Log.i("TIME", "RotateTime: " + (finishTime - startTime) / 1000000);
- }
Advertisement
Add Comment
Please, Sign In to add comment