Note that there are some explanatory texts on larger screens.

plurals
  1. POPreview images in Portrait screen mode issues in Samsung Glaxy NoteII for Android apps
    text
    copied!<p>I am having problem with the preview of the captured pictures. </p> <p>I have set up the ImageView to preview the image in the xml file. Once the picture is taken, i get a save or discard preview of the taken images. </p> <p>I can preview the captured photo in the ImageView only when i capture the photo in Landscape screen mode and declare the orientation as android:screenOrientation="portrait" in the Android Manifest file. I can preview the image in the Image View in portrait view! Screen shot: Landscape Screen mode: <img src="https://i.stack.imgur.com/sBgxR.png" alt="Before previewing"></p> <p><img src="https://i.stack.imgur.com/2Knkf.png" alt="preview"></p> <p>But, once the photo is captured in portrait screen mode, after clicking on the 'Save' button, it does not display any preview on the ImageView.</p> <p>Screen shot: <img src="https://i.stack.imgur.com/VmqmI.png" alt="Before Preview"> <img src="https://i.stack.imgur.com/FogbW.png" alt="On preview"></p> <p>I am using Samsung Glaxy Note II. </p> <p>I have tried this code:</p> <pre><code>public Bitmap decodeFile(String path) {//you can provide file path here int orientation; try { if (path == null) { return null; } // decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; // Find the correct scale value. It should be the power of 2. final int REQUIRED_SIZE = 70; int width_tmp = o.outWidth, height_tmp = o.outHeight; int scale = 0; while (true) { if (width_tmp / 2 &lt; REQUIRED_SIZE || height_tmp / 2 &lt; REQUIRED_SIZE) break; width_tmp /= 2; height_tmp /= 2; scale++; } // decode with inSampleSize BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = scale; Bitmap bm = BitmapFactory.decodeFile(path, o2); Bitmap bitmap = bm; ExifInterface exif = new ExifInterface(path); orientation = exif .getAttributeInt(ExifInterface.TAG_ORIENTATION, 1); Log.e("ExifInteface .........", "rotation ="+orientation); //exif.setAttribute(ExifInterface.ORIENTATION_ROTATE_90, 90); Log.e("orientation", "" + orientation); Matrix m = new Matrix(); if ((orientation == ExifInterface.ORIENTATION_ROTATE_180)) { m.postRotate(180); //m.postScale((float) bm.getWidth(), (float) bm.getHeight()); // if(m.preRotate(90)){ Log.e("in orientation", "" + orientation); bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), m, true); return bitmap; } else if (orientation == ExifInterface.ORIENTATION_ROTATE_90) { m.postRotate(90); Log.e("in orientation", "" + orientation); bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), m, true); return bitmap; } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) { m.postRotate(270); Log.e("in orientation", "" + orientation); bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), m, true); return bitmap; } return bitmap; } catch (Exception e) { return null; } } </code></pre> <p>My xml file to display preview and to do other functions:</p> <pre><code>&lt;ImageView android:id="@+id/ivReturnedPics" android:layout_width="168dp" android:layout_height="168dp" android:layout_gravity="center" android:src="@drawable/testsh" android:padding="3dp" /&gt; </code></pre> <p><strong>I am using the code:</strong> decodeFile(filePath); ivv.setImageBitmap(bmp);</p> <p>Thanks for your help in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload