Skip to main content

Posts

Showing posts from July, 2018

How to clear the orientation issue on Camera Image

We will be taking a picture with this library and create a Bitmap and set it in an ImageView as follow public void onPictureTaken(CameraView cameraView, byte[] data) {      Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);      imageView.setImageBitmap(bitmap); } This will work fine on most of the devices however there are some exceptional devices too, where the picture orientation appears to be incorrectly rotated 90 degrees to the left when the device orientations is portrait. Solution to overcome this issue in your application  Trick :  Check if the  width > height  of the image then rotate by 90  Follow the steps: private static int fixOrientation(Bitmap bitmap) {         if (bitmap.getWidth() > bitmap.getHeight()) {             return 90;         }         return 0;     } Call this method to apply the rotation if needed public static Bitmap flipIMage(Bitmap bitmap) {         //Moustafa: fix