Byte array for bitmap:
Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
Use this to rotate the image by providing a right angle (180):
public Bitmap rotateImage(int angle, Bitmap bitmapSrc) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(bitmapSrc, 0, 0, bitmapSrc.getWidth(), bitmapSrc.getHeight(), matrix, true); }
Then go back to the array:
ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] flippedImageByteArray = stream.toByteArray();
Voicu
source share