List of usage examples for android.media ExifInterface TAG_ORIENTATION
String TAG_ORIENTATION
To view the source code for android.media ExifInterface TAG_ORIENTATION.
Click Source Link
From source file:com.owncloud.android.utils.BitmapUtils.java
/** * Rotate bitmap according to EXIF orientation. * Cf. http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/ * @param bitmap Bitmap to be rotated//from w w w. j ava 2 s. co m * @param storagePath Path to source file of bitmap. Needed for EXIF information. * @return correctly EXIF-rotated bitmap */ public static Bitmap rotateImage(final Bitmap bitmap, final String storagePath) { try { ExifInterface exifInterface = new ExifInterface(storagePath); final int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1); Matrix matrix = new Matrix(); // 1: nothing to do switch (orientation) { case ExifInterface.ORIENTATION_FLIP_HORIZONTAL: matrix.postScale(-1.0f, 1.0f); break; case ExifInterface.ORIENTATION_ROTATE_180: matrix.postRotate(180); break; case ExifInterface.ORIENTATION_FLIP_VERTICAL: matrix.postScale(1.0f, -1.0f); break; case ExifInterface.ORIENTATION_TRANSPOSE: matrix.postRotate(-90); matrix.postScale(1.0f, -1.0f); break; case ExifInterface.ORIENTATION_ROTATE_90: matrix.postRotate(90); break; case ExifInterface.ORIENTATION_TRANSVERSE: matrix.postRotate(90); matrix.postScale(1.0f, -1.0f); break; case ExifInterface.ORIENTATION_ROTATE_270: matrix.postRotate(270); break; } // Rotate the bitmap final Bitmap resultBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); if (resultBitmap != bitmap) { bitmap.recycle(); } return resultBitmap; } catch (Exception exception) { Log_OC.e("BitmapUtil", "Could not rotate the image: " + storagePath); return bitmap; } }
From source file:com.haru.ui.image.workers.MediaProcessorThread.java
private String compressAndSaveImage(String fileImage, int scale) throws Exception { try {//from w w w . j a v a 2 s . c o m ExifInterface exif = new ExifInterface(fileImage); String width = exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH); String length = exif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); int rotate = 0; if (/* TODO: DEBUG */ true) { Log.i(TAG, "Before: " + width + "x" + length); } switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotate = -90; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; } int w = Integer.parseInt(width); int l = Integer.parseInt(length); int what = w > l ? w : l; Options options = new Options(); if (what > 1500) { options.inSampleSize = scale * 4; } else if (what > 1000 && what <= 1500) { options.inSampleSize = scale * 3; } else if (what > 400 && what <= 1000) { options.inSampleSize = scale * 2; } else { options.inSampleSize = scale; } if (/* TODO: DEBUG */ true) { Log.i(TAG, "Scale: " + (what / options.inSampleSize)); Log.i(TAG, "Rotate: " + rotate); } Bitmap bitmap = BitmapFactory.decodeFile(fileImage, options); File original = new File(fileImage); File file = new File((original.getParent() + File.separator + original.getName().replace(".", "_fact_" + scale + "."))); FileOutputStream stream = new FileOutputStream(file); if (rotate != 0) { Matrix matrix = new Matrix(); matrix.setRotate(rotate); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); } bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); if (/* TODO: DEBUG */ true) { ExifInterface exifAfter = new ExifInterface(file.getAbsolutePath()); String widthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_WIDTH); String lengthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_LENGTH); if (/* TODO: DEBUG */ true) { Log.i(TAG, "After: " + widthAfter + "x" + lengthAfter); } } stream.flush(); stream.close(); return file.getAbsolutePath(); } catch (IOException e) { e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw new Exception("Corrupt or deleted file???"); } }
From source file:com.cars.manager.utils.imageChooser.threads.MediaProcessorThread.java
private String compressAndSaveImage(String fileImage, int scale) throws Exception { try {/* ww w. j av a 2 s . co m*/ ExifInterface exif = new ExifInterface(fileImage); String width = exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH); String length = exif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); int rotate = 0; if (Config.DEBUG) { Log.i(TAG, "Before: " + width + "x" + length); } switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotate = -90; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; } int w = Integer.parseInt(width); int l = Integer.parseInt(length); int what = w > l ? w : l; Options options = new Options(); if (what > 1500) { options.inSampleSize = scale * 4; } else if (what > 1000 && what <= 1500) { options.inSampleSize = scale * 3; } else if (what > 400 && what <= 1000) { options.inSampleSize = scale * 2; } else { options.inSampleSize = scale; } if (Config.DEBUG) { Log.i(TAG, "Scale: " + (what / options.inSampleSize)); Log.i(TAG, "Rotate: " + rotate); } Bitmap bitmap = BitmapFactory.decodeFile(fileImage, options); File original = new File(fileImage); File file = new File((original.getParent() + File.separator + original.getName().replace(".", "_fact_" + scale + "."))); FileOutputStream stream = new FileOutputStream(file); if (rotate != 0) { Matrix matrix = new Matrix(); matrix.setRotate(rotate); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); } bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); if (Config.DEBUG) { ExifInterface exifAfter = new ExifInterface(file.getAbsolutePath()); String widthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_WIDTH); String lengthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_LENGTH); if (Config.DEBUG) { Log.i(TAG, "After: " + widthAfter + "x" + lengthAfter); } } stream.flush(); stream.close(); return file.getAbsolutePath(); } catch (IOException e) { e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw new Exception("Corrupt or deleted file???"); } }
From source file:Main.java
public static void copyExifData(File srcImgFile, File dstImgFile) throws IOException { ExifInterface srcExif = new ExifInterface(srcImgFile.getCanonicalPath()); ExifInterface dstExif = new ExifInterface(dstImgFile.getCanonicalPath()); int buildSDKVersion = Build.VERSION.SDK_INT; // From API 11 if (buildSDKVersion >= Build.VERSION_CODES.HONEYCOMB) { if (srcExif.getAttribute(ExifInterface.TAG_APERTURE) != null) { dstExif.setAttribute(ExifInterface.TAG_APERTURE, srcExif.getAttribute(ExifInterface.TAG_APERTURE)); }// w w w. jav a 2 s. c o m if (srcExif.getAttribute(ExifInterface.TAG_EXPOSURE_TIME) != null) { dstExif.setAttribute(ExifInterface.TAG_EXPOSURE_TIME, srcExif.getAttribute(ExifInterface.TAG_EXPOSURE_TIME)); } if (srcExif.getAttribute(ExifInterface.TAG_ISO) != null) { dstExif.setAttribute(ExifInterface.TAG_ISO, srcExif.getAttribute(ExifInterface.TAG_ISO)); } } // From API 9 if (buildSDKVersion >= Build.VERSION_CODES.GINGERBREAD) { if (srcExif.getAttribute(ExifInterface.TAG_GPS_ALTITUDE) != null) { dstExif.setAttribute(ExifInterface.TAG_GPS_ALTITUDE, srcExif.getAttribute(ExifInterface.TAG_GPS_ALTITUDE)); } if (srcExif.getAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF) != null) { dstExif.setAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF, srcExif.getAttribute(ExifInterface.TAG_GPS_ALTITUDE_REF)); } } // From API 8 if (buildSDKVersion >= Build.VERSION_CODES.FROYO) { if (srcExif.getAttribute(ExifInterface.TAG_FOCAL_LENGTH) != null) { dstExif.setAttribute(ExifInterface.TAG_FOCAL_LENGTH, srcExif.getAttribute(ExifInterface.TAG_FOCAL_LENGTH)); } if (srcExif.getAttribute(ExifInterface.TAG_GPS_DATESTAMP) != null) { dstExif.setAttribute(ExifInterface.TAG_GPS_DATESTAMP, srcExif.getAttribute(ExifInterface.TAG_GPS_DATESTAMP)); } if (srcExif.getAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD) != null) { dstExif.setAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD, srcExif.getAttribute(ExifInterface.TAG_GPS_PROCESSING_METHOD)); } if (srcExif.getAttribute(ExifInterface.TAG_GPS_TIMESTAMP) != null) { dstExif.setAttribute(ExifInterface.TAG_GPS_TIMESTAMP, srcExif.getAttribute(ExifInterface.TAG_GPS_TIMESTAMP)); } } if (srcExif.getAttribute(ExifInterface.TAG_DATETIME) != null) { dstExif.setAttribute(ExifInterface.TAG_DATETIME, srcExif.getAttribute(ExifInterface.TAG_DATETIME)); } if (srcExif.getAttribute(ExifInterface.TAG_FLASH) != null) { dstExif.setAttribute(ExifInterface.TAG_FLASH, srcExif.getAttribute(ExifInterface.TAG_FLASH)); } if (srcExif.getAttribute(ExifInterface.TAG_GPS_LATITUDE) != null) { dstExif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, srcExif.getAttribute(ExifInterface.TAG_GPS_LATITUDE)); } if (srcExif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF) != null) { dstExif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, srcExif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF)); } if (srcExif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE) != null) { dstExif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, srcExif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE)); } if (srcExif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF) != null) { dstExif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, srcExif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF)); } if (srcExif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH) != null) { dstExif.setAttribute(ExifInterface.TAG_IMAGE_LENGTH, srcExif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH)); } if (srcExif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH) != null) { dstExif.setAttribute(ExifInterface.TAG_IMAGE_WIDTH, srcExif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH)); } if (srcExif.getAttribute(ExifInterface.TAG_MAKE) != null) { dstExif.setAttribute(ExifInterface.TAG_MAKE, srcExif.getAttribute(ExifInterface.TAG_MAKE)); } if (srcExif.getAttribute(ExifInterface.TAG_MODEL) != null) { dstExif.setAttribute(ExifInterface.TAG_MODEL, srcExif.getAttribute(ExifInterface.TAG_MODEL)); } if (srcExif.getAttribute(ExifInterface.TAG_ORIENTATION) != null) { dstExif.setAttribute(ExifInterface.TAG_ORIENTATION, srcExif.getAttribute(ExifInterface.TAG_ORIENTATION)); } if (srcExif.getAttribute(ExifInterface.TAG_WHITE_BALANCE) != null) { dstExif.setAttribute(ExifInterface.TAG_WHITE_BALANCE, srcExif.getAttribute(ExifInterface.TAG_WHITE_BALANCE)); } dstExif.saveAttributes(); }
From source file:com.wots.lutmaar.CustomView.imagechooser.threads.MediaProcessorThread.java
private String compressAndSaveImage(String fileImage, int scale) throws Exception { try {//w w w . j a va 2 s .c o m ExifInterface exif = new ExifInterface(fileImage); String width = exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH); String length = exif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); int rotate = 0; if (BuildConfig.DEBUG) { Log.i(TAG, "Before: " + width + "x" + length); } switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotate = -90; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; } int w = Integer.parseInt(width); int l = Integer.parseInt(length); int what = w > l ? w : l; Options options = new Options(); if (what > 1500) { options.inSampleSize = scale * 4; } else if (what > 1000 && what <= 1500) { options.inSampleSize = scale * 3; } else if (what > 400 && what <= 1000) { options.inSampleSize = scale * 2; } else { options.inSampleSize = scale; } if (BuildConfig.DEBUG) { Log.i(TAG, "Scale: " + (what / options.inSampleSize)); Log.i(TAG, "Rotate: " + rotate); } Bitmap bitmap = BitmapFactory.decodeFile(fileImage, options); File original = new File(fileImage); File file = new File((original.getParent() + File.separator + original.getName().replace(".", "_fact_" + scale + "."))); FileOutputStream stream = new FileOutputStream(file); if (rotate != 0) { Matrix matrix = new Matrix(); matrix.setRotate(rotate); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); } /* if (scale == 1) bitmap = Bitmap.createScaledBitmap(bitmap, 240, 260, true);*/ bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); if (BuildConfig.DEBUG) { ExifInterface exifAfter = new ExifInterface(file.getAbsolutePath()); String widthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_WIDTH); String lengthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_LENGTH); if (BuildConfig.DEBUG) { Log.i(TAG, "After: " + widthAfter + "x" + lengthAfter); } } stream.flush(); stream.close(); return file.getAbsolutePath(); } catch (IOException e) { e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw new Exception("Corrupt or deleted file???"); } }
From source file:com.amytech.android.library.views.imagechooser.threads.MediaProcessorThread.java
private String compressAndSaveImage(String fileImage, int scale) throws Exception { try {/*from w w w .java 2 s. co m*/ ExifInterface exif = new ExifInterface(fileImage); String width = exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH); String length = exif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); int rotate = 0; if (BuildConfig.DEBUG) { Log.i(TAG, "Before: " + width + "x" + length); } switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: rotate = -90; break; case ExifInterface.ORIENTATION_ROTATE_180: rotate = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: rotate = 90; break; } int w = Integer.parseInt(width); int l = Integer.parseInt(length); int what = w > l ? w : l; Options options = new Options(); if (what > 1500) { options.inSampleSize = scale * 4; } else if (what > 1000 && what <= 1500) { options.inSampleSize = scale * 3; } else if (what > 400 && what <= 1000) { options.inSampleSize = scale * 2; } else { options.inSampleSize = scale; } if (BuildConfig.DEBUG) { Log.i(TAG, "Scale: " + (what / options.inSampleSize)); Log.i(TAG, "Rotate: " + rotate); } Bitmap bitmap = BitmapFactory.decodeFile(fileImage, options); File original = new File(fileImage); File file = new File((original.getParent() + File.separator + original.getName().replace(".", "_fact_" + scale + "."))); FileOutputStream stream = new FileOutputStream(file); if (rotate != 0) { Matrix matrix = new Matrix(); matrix.setRotate(rotate); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false); } bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); if (BuildConfig.DEBUG) { ExifInterface exifAfter = new ExifInterface(file.getAbsolutePath()); String widthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_WIDTH); String lengthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_LENGTH); if (BuildConfig.DEBUG) { Log.i(TAG, "After: " + widthAfter + "x" + lengthAfter); } } stream.flush(); stream.close(); return file.getAbsolutePath(); } catch (IOException e) { e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw new Exception("Corrupt or deleted file???"); } }
From source file:com.pdftron.pdf.utils.ViewerUtils.java
public static Map readImageIntent(Intent data, Context context, Uri outputFileUri) throws FileNotFoundException, Exception { final boolean isCamera; if (data == null || data.getData() == null) { isCamera = true;/* w w w . j av a 2s . c om*/ } else { final String action = data.getAction(); if (action == null) { isCamera = false; } else { isCamera = action.equals(MediaStore.ACTION_IMAGE_CAPTURE); } } Uri imageUri; if (isCamera) { imageUri = outputFileUri; AnalyticsHandlerAdapter.getInstance().sendEvent(AnalyticsHandlerAdapter.CATEGORY_FILEBROWSER, "Create new document from camera selected"); } else { imageUri = data.getData(); AnalyticsHandlerAdapter.getInstance().sendEvent(AnalyticsHandlerAdapter.CATEGORY_FILEBROWSER, "Create new document from local image file selected"); } String filePath; if (isCamera) { filePath = imageUri.getPath(); } else { filePath = Utils.getRealPathFromImageURI(context, imageUri); if (Utils.isNullOrEmpty(filePath)) { filePath = imageUri.getPath(); } } // try to get bitmap Bitmap bitmap = Utils.getBitmapFromImageUri(context, imageUri, filePath); // if a file is selected, check if it is an image file if (!isCamera) { // if type is null if (context.getContentResolver().getType(imageUri) == null) { String extension = MimeTypeMap.getFileExtensionFromUrl(imageUri.getPath()); final String[] extensions = { "jpeg", "jpg", "tiff", "tif", "gif", "png", "bmp" }; // if file extension is not an image extension if (!Arrays.asList(extensions).contains(extension) && extension != null && !extension.equals("")) { throw new FileNotFoundException("file extension is not an image extension"); } // if type is not an image } else if (!context.getContentResolver().getType(imageUri).startsWith("image/")) { throw new FileNotFoundException("type is not an image"); } } ////////////////// Determine if image needs to be rotated /////////////////// File imageFile = new File(imageUri.getPath()); ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath()); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); int imageRotation = 0; switch (orientation) { case ExifInterface.ORIENTATION_ROTATE_270: imageRotation = 270; break; case ExifInterface.ORIENTATION_ROTATE_180: imageRotation = 180; break; case ExifInterface.ORIENTATION_ROTATE_90: imageRotation = 90; break; } // in some devices (mainly Samsung), the EXIF is not saved with the image so look at the content // resolver as a second source of the image's rotation if (imageRotation == 0) { String[] orientationColumn = { MediaStore.Images.Media.ORIENTATION }; Cursor cur = context.getContentResolver().query(imageUri, orientationColumn, null, null, null); orientation = -1; if (cur != null && cur.moveToFirst()) { orientation = cur.getInt(cur.getColumnIndex(orientationColumn[0])); } if (orientation > 0) { imageRotation = orientation; } } if (imageRotation != 0) { Matrix matrix = new Matrix(); matrix.postRotate(imageRotation); bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } Map<String, Object> output = new HashMap<>(); output.put("bitmap", bitmap); output.put("uri", imageUri); output.put("path", filePath); output.put("camera", isCamera); return output; }
From source file:ir.rasen.charsoo.controller.image_loader.core.decode.BaseImageDecoder.java
protected ExifInfo defineExifOrientation(String imageUri) { int rotation = 0; boolean flip = false; try {//from w ww .j av a 2s . c om ExifInterface exif = new ExifInterface(Scheme.FILE.crop(imageUri)); int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (exifOrientation) { case ExifInterface.ORIENTATION_FLIP_HORIZONTAL: flip = true; case ExifInterface.ORIENTATION_NORMAL: rotation = 0; break; case ExifInterface.ORIENTATION_TRANSVERSE: flip = true; case ExifInterface.ORIENTATION_ROTATE_90: rotation = 90; break; case ExifInterface.ORIENTATION_FLIP_VERTICAL: flip = true; case ExifInterface.ORIENTATION_ROTATE_180: rotation = 180; break; case ExifInterface.ORIENTATION_TRANSPOSE: flip = true; case ExifInterface.ORIENTATION_ROTATE_270: rotation = 270; break; } } catch (IOException e) { L.w("Can't read EXIF tags from file [%s]", imageUri); } return new ExifInfo(rotation, flip); }
From source file:kr.wdream.ui.Components.AvatarUpdater.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == 13) { PhotoViewer.getInstance().setParentActivity(parentFragment.getParentActivity()); int orientation = 0; try { ExifInterface ei = new ExifInterface(currentPicturePath); int exif = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); switch (exif) { case ExifInterface.ORIENTATION_ROTATE_90: orientation = 90;//from w w w . j av a2s . c o m break; case ExifInterface.ORIENTATION_ROTATE_180: orientation = 180; break; case ExifInterface.ORIENTATION_ROTATE_270: orientation = 270; break; } } catch (Exception e) { FileLog.e("tmessages", e); } final ArrayList<Object> arrayList = new ArrayList<>(); arrayList.add(new MediaController.PhotoEntry(0, 0, 0, currentPicturePath, orientation, false)); PhotoViewer.getInstance().openPhotoForSelect(arrayList, 0, 1, new PhotoViewer.EmptyPhotoViewerProvider() { @Override public void sendButtonPressed(int index) { String path = null; MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) arrayList .get(0); if (photoEntry.imagePath != null) { path = photoEntry.imagePath; } else if (photoEntry.path != null) { path = photoEntry.path; } Bitmap bitmap = ImageLoader.loadBitmap(path, null, 800, 800, true); processBitmap(bitmap); } @Override public boolean allowCaption() { return false; } }, null); AndroidUtilities.addMediaToGallery(currentPicturePath); currentPicturePath = null; } else if (requestCode == 14) { if (data == null || data.getData() == null) { return; } startCrop(null, data.getData()); } } }
From source file:om.sstvencoder.MainActivity.java
public int getOrientation(ContentResolver resolver, Uri uri) { int orientation = 0; try {/*from w w w. ja v a 2s . c o m*/ Cursor cursor = resolver.query(uri, new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null, null, null); if (cursor.moveToFirst()) orientation = cursor.getInt(0); cursor.close(); } catch (Exception ignore) { try { ExifInterface exif = new ExifInterface(uri.getPath()); orientation = Utility.convertToDegrees(exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0)); } catch (Exception ex) { showOrientationErrorMessage(uri, ex); } } return orientation; }