public static Bitmap rotateImage(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); }
Matrix matrix = new Matrix(); imageView.setScaleType(ImageView.ScaleType.MATRIX); //required matrix.postRotate((float) angle, pivotX, pivotY); imageView.setImageMatrix(matrix);
int rotate = 0; try { File imageFile = new File(sourcepath); ExifInterface exif = new ExifInterface( imageFile.getAbsolutePath()); int orientation = exif.getAttributeInt( ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotate = 270; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; } } catch (Exception e) { e.printStackTrace(); } Matrix matrix = new Matrix(); matrix.postRotate(rotate); bitmap = Bitmap.createBitmap(bitmap , 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
Matrix matrix = new Matrix(); ExifInterface exifReader = new ExifInterface(filePath); int orientation = exifReader.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1); if (orientation ==ExifInterface.ORIENTATION_NORMAL) { // Do nothing. The original image is fine. } else if (orientation == ExifInterface.ORIENTATION_ROTATE_90) { matrix.postRotate(90); } else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) { matrix.postRotate(180); } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) { matrix.postRotate(270); }
Matrix matrix = new Matrix(); matrix.postRotate(90); Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmapOrg,width,height,true); Bitmap rotatedBitmap = Bitmap.createBitmap(scaledBitmap , 0, 0, scaledBitmap .getWidth(), scaledBitmap .getHeight(), matrix, true);
try { File imageFile = new File(cursor.getString(0)); ExifInterface exif = new ExifInterface( imageFile.getAbsolutePath()); int orientation = exif.getAttributeInt( ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotate = 270; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; } Log.v("", "Exif orientation: " + orientation); } catch (Exception e) { e.printStackTrace(); } Matrix matrix = new Matrix(); matrix.postRotate(rotate); bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); testImage.setImageBitmap(null); testImage.setImageBitmap(bmp);
ExifInterface exif = new ExifInterface(selectedImage); exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1); if(orientation == 3 || orientation == 6 || orientation == 8 ){ Matrix matrix = new Matrix(); if (orientation == 6) matrix.postRotate(90); else if (orientation == 3) matrix.postRotate(180); else if (orientation == 8) matrix.postRotate(270); result = Bitmap.createBitmap(result, 0, 0, result.getWidth(), result.getHeight(), matrix, true); // rotating bitmap }
Matrix matrix = new Matrix(); matrix.postRotate(90); rotatedBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth(), sourceBitmap.getHeight(), matrix, true);
public static Bitmap RotateBitmap(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); }
Bitmap bitmap = bm; ExifInterface exif = new ExifInterface(path); .getAttributeInt(ExifInterface.TAG_ORIENTATION, 1); Matrix m = new Matrix(); m.postRotate(180); 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(), 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(),
Matrix matrix = new Matrix(); ExifInterface exifReader = new ExifInterface(filePath); int orientation = exifReader.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1); if (orientation ==ExifInterface.ORIENTATION_NORMAL) { // Do nothing. The original image is fine. } else if (orientation == ExifInterface.ORIENTATION_ROTATE_90) { matrix.postRotate(90); } else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) { matrix.postRotate(180); } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) { matrix.postRotate(270); }
Matrix matrix = new Matrix(); matrix.postRotate(90); rotated = Bitmap.createBitmap(original, 0, 0, original.getWidth(), original.getHeight(), matrix, true);
public static Bitmap RotateBitmap(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); }
// Adjustment for orientation of images public static Matrix adjustOrientation(String path) { Matrix matrix = new Matrix(); try { ExifInterface exifReader = new ExifInterface(path); int orientation = exifReader.getAttributeInt( ExifInterface.TAG_ORIENTATION, -1); if (orientation == ExifInterface.ORIENTATION_NORMAL) { // do nothing } else if (orientation == ExifInterface.ORIENTATION_ROTATE_90) { matrix.postRotate(90); } else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) { matrix.postRotate(180); } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) { matrix.postRotate(270); } } catch (IOException e) { e.printStackTrace(); } return matrix; }
ExifInterface exif; try { exif = new ExifInterface(filePath); int orientation = exif.getAttributeInt( ExifInterface.TAG_ORIENTATION, 0); Log.d("EXIF", "Exif: " + orientation); Matrix matrix = new Matrix(); if (orientation == 6) { matrix.postRotate(90); Log.d("EXIF", "Exif: " + orientation); } else if (orientation == 3) { matrix.postRotate(180); Log.d("EXIF", "Exif: " + orientation); } else if (orientation == 8) { matrix.postRotate(270); Log.d("EXIF", "Exif: " + orientation); }
public void fixOrientation() { if (mBitmap.getWidth() > mBitmap.getHeight()) { Matrix matrix = new Matrix(); matrix.postRotate(90); mBitmap = Bitmap.createBitmap(mBitmap , 0, 0, mBitmap.getWidth(), mBitmap.getHeight(), matrix, true); } }
imageView = (ImageView) findViewById(R.id.imageView); Bitmap myImg = BitmapFactory.decodeResource(getResources(), R.drawable.image); Matrix matrix = new Matrix(); matrix.postRotate(30); Bitmap rotated = Bitmap.createBitmap(myImg, 0, 0, myImg.getWidth(), myImg.getHeight(), matrix, true); imageView.setImageBitmap(rotated);
File f = new File(filePath); ExifInterface exif = new ExifInterface(f.getPath()); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); int angle = 0; if (orientation == ExifInterface.ORIENTATION_ROTATE_90) { angle = 90; } else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) { angle = 180; } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) { angle = 270; } Matrix mat = new Matrix(); mat.postRotate(angle); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 2;
ExifInterface exif; try { exif = new ExifInterface(filePath); int orientation = exif.getAttributeInt( ExifInterface.TAG_ORIENTATION, 0); Log.d("EXIF", "Exif: " + orientation); Matrix matrix = new Matrix(); if (orientation == 6) { matrix.postRotate(90); Log.d("EXIF", "Exif: " + orientation); } else if (orientation == 3) { matrix.postRotate(180); Log.d("EXIF", "Exif: " + orientation); } else if (orientation == 8) { matrix.postRotate(270); Log.d("EXIF", "Exif: " + orientation); }
Uri imageUri = intent.getData(); String[] orientationColumn = {MediaStore.Images.Media.ORIENTATION}; Cursor cur = managedQuery(imageUri, orientationColumn, null, null, null); int orientation = -1; if (cur != null && cur.moveToFirst()) { orientation = cur.getInt(cur.getColumnIndex(orientationColumn[0])); } Matrix matrix = new Matrix(); matrix.postRotate(orientation);