The following is a method used to flip the image which is stored as byte array and return the result in byte array.
private byte[] flipImage(byte[] data, int flip) {
Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
Matrix matrix = new Matrix();
switch (flip){
case 1: matrix.preScale(1.0f, -1.0f); break; //flip vertical
case 2: matrix.preScale(-1.0f, 1.0f); break; //flip horizontal
default: matrix.preScale(1.0f, 1.0f); //No flip
}
Bitmap bmp2 = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp2.compress(Bitmap.CompressFormat.JPEG, 100, stream);
return stream.toByteArray();
}
If you want a vertical flipped image then pass 1 as flip value and for horizontal flip pass 2.
For Eg:
@Override
public void onPictureTaken(byte[] data, Camera camera) {
byte[] verticalFlippedImage = flipImage(data,1);
byte[] horizontalFlippedImage = flipImage(data,2);
}