Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

 3 Answer(s)

  • Hi,
    I was facing same issue in Samsung galaxy, but using targetWidth and targetHeight in getPicture function solved my problem,

    navigator.camera.getPicture( onPhotoDataSuccess, onFail, { quality: 75, targetWidth:1000, 
                targetHeight: 1000, correctOrientation: true,
                destinationType: Camera.DestinationType.DATA_URL 
            } );
    


    Hope this will help you..

  • Here is a code which will handle the orientation issue in most of the device.

            mImagePath - is the path of source image
            exif - ExifInterface exif
            bmpPic1 - is bitmap after orientation change
            context - is the application context
    
    
        Matrix mat = new Matrix();
    
            try {
                exif = new ExifInterface(mImagePath);
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            String orientstring = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
            int orientation = orientstring != null ? Integer.parseInt(orientstring) : ExifInterface.ORIENTATION_NORMAL;
            int rotateangle = 0;
            if (orientation == ExifInterface.ORIENTATION_ROTATE_90)
                rotateangle = 90;
            if (orientation == ExifInterface.ORIENTATION_ROTATE_180)
                rotateangle = 180;
            if (orientation == ExifInterface.ORIENTATION_ROTATE_270)
                rotateangle = 270;
    
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = 4;
    
            Bitmap bitmap = BitmapFactory.decodeFile(mImagePath, options);
    
            mat.setRotate(rotateangle, (float) bitmap.getWidth() / 2, (float) bitmap.getHeight() / 2);
    
            File f = new File(mImagePath);
            Bitmap bmpPic;
            try {
                bmpPic = BitmapFactory.decodeStream(new FileInputStream(f), null, null);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            Bitmap bmpPic1 = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), mat, true);
            bmpPic1 = AppUtility.getRotatedBitmap(mImagePath, bmpPic1, context);
    

    Please mark the answer correct if found helpful.

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: