public static byte[] rotate180(byte[] data, int imageWidth, int imageHeight) {
        int n = imageWidth * imageHeight;
        byte[] yuv = new byte[n];

        int i = n - 1;
        for (int j = 0; j < n; j++) {
            yuv[i] = data[j];
            i--;
        }
        return yuv;
    }
Rotate an image by 180 degrees.

@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