RTEditor/src/main/java/com/onegravity/rteditor/media/crop/CropImageActivity.java
private Bitmap getBitmap(String path) {
        Uri uri = MediaUtils.createFileUri(path);
        InputStream in = null;
        try {
            in = getContentResolver().openInputStream(uri);

            // Decode image size
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeStream(in, null, options);
            Helper.closeQuietly(in);

            // compute scale factor to ensure that the image is smaller than
            // IMAGE_MAX_SIZE
            float maxSize = Math.max(options.outWidth, options.outHeight);
            float scale = maxSize > IMAGE_MAX_SIZE ? maxSize / IMAGE_MAX_SIZE
                    : 1.0f;

            while ((maxSize / scale) > 8) {
                try {
                    return getBitmap(in, uri, scale);
                } catch (Throwable e) {
                    Log.w(getClass().getSimpleName(),
                            "bitmap could not be created (probably out of memory), decreasing size and retrying");
                    scale *= 2f;
                }
            }
        } catch (IOException e) {
            Log.e(getClass().getSimpleName(), "file " + path + " not found");
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "error while opening image", e);
        } finally {
            Helper.closeQuietly(in);
        }
        return null;
    }
private Bitmap getBitmap(String path) {
        Uri uri = MediaUtils.createFileUri(path);
        InputStream in = null;
        try {
            in = getContentResolver().openInputStream(uri);

            // Decode image size
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeStream(in, null, options);
            Helper.closeQuietly(in);

            // compute scale factor to ensure that the image is smaller than
            // IMAGE_MAX_SIZE
            float maxSize = Math.max(options.outWidth, options.outHeight);
            float scale = maxSize > IMAGE_MAX_SIZE ? maxSize / IMAGE_MAX_SIZE
                    : 1.0f;

            while ((maxSize / scale) > 8) {
                try {
                    return getBitmap(in, uri, scale);
                } catch (Throwable e) {
                    Log.w(getClass().getSimpleName(),
                            "bitmap could not be created (probably out of memory), decreasing size and retrying");
                    scale *= 2f;
                }
            }
        } catch (IOException e) {
            Log.e(getClass().getSimpleName(), "file " + path + " not found");
        } catch (Exception e) {
            Log.e(getClass().getSimpleName(), "error while opening image", e);
        } finally {
            Helper.closeQuietly(in);
        }
        return null;
    }
private Bitmap getBitmap ( String path ) { Uri uri = MediaUtils . createFileUri ( path ) ; InputStream in = null ; try { in = getContentResolver ( ) . openInputStream ( uri ) ; // Decode image size BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . inJustDecodeBounds = true ; BitmapFactory . decodeStream ( in , null , options ) ; Helper . closeQuietly ( in ) ; // compute scale factor to ensure that the image is smaller than // IMAGE_MAX_SIZE float maxSize = Math . max ( options . outWidth , options . outHeight ) ; float scale = maxSize > IMAGE_MAX_SIZE ? maxSize / IMAGE_MAX_SIZE : 1.0f ; while ( ( maxSize / scale ) > 8 ) { try { return getBitmap ( in , uri , scale ) ; } catch ( Throwable e ) { Log . w ( getClass ( ) . getSimpleName ( ) , "bitmap could not be created (probably out of memory), decreasing size and retrying" ) ; scale *= 2f ; } } } catch ( IOException e ) { Log . e ( getClass ( ) . getSimpleName ( ) , "file " + path + " not found" ) ; } catch ( Exception e ) { Log . e ( getClass ( ) . getSimpleName ( ) , "error while opening image" , e ) ; } finally { Helper . closeQuietly ( in ) ; } return null ; }
****************************************** Private Methods *******************************************
****************************************** Private Methods *******************************************