Note that there are some explanatory texts on larger screens.

plurals
  1. POimage rotation not working on Samsung Galaxy Nexus android
    primarykey
    data
    text
    <p>I've tested this code snippet on about 25 devices and it works great on all of them except a Samsung Galaxy Nexus that I'm trying to test with now.</p> <p>Here is the method and I apologize for not trimming it down to find the exact spot that's throwing the exception, but eclipse's debugging is doodoo.</p> <pre><code>private void setupImageView() { imageLocation = currentPhotoPath; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); //int rotationForImage = getRotationForImage(imageLocation); int rotationForImage = (whichCamera == 0 ? 90 : 270); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} } imageView.setImageBitmap(bitmap); } </code></pre> <p>anyone know what Samsung does differently with the nexus that would cause this to throw an exception? It works fine on a Galaxy S III</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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