public static byte[] rotateCCW(byte[] data, int imageWidth, int imageHeight) {
        int n = imageWidth * imageHeight;
        byte[] yuv = new byte[n];
        int i = n - 1;
        for (int x = 0; x < imageWidth; x++) {
            for (int y = imageHeight - 1; y >= 0; y--) {
                yuv[i] = data[y * imageWidth + x];
                i--;
            }
        }
        return yuv;
    }
Rotate an image by 90 degrees CCW.

@param data        the image data, in with the first width * height bytes being the luminance data.
@param imageWidth  the width of the image
@param imageHeight the height of the image
@return the rotated bytes
zxing-android-embedded/src/com/journeyapps/barcodescanner/RawImageData.java