Example usage for android.graphics BitmapFactory decodeFile

List of usage examples for android.graphics BitmapFactory decodeFile

Introduction

In this page you can find the example usage for android.graphics BitmapFactory decodeFile.

Prototype

public static Bitmap decodeFile(String pathName, Options opts) 

Source Link

Document

Decode a file path into a bitmap.

Usage

From source file:Main.java

public static boolean isBitmap(String filePath) {

    BitmapFactory.Options options = new BitmapFactory.Options();

    options.inJustDecodeBounds = true;//  w w w  .j  av a  2s.  co m

    BitmapFactory.decodeFile(filePath, options);

    if (options.outWidth <= 0 || options.outHeight <= 0) {

        return false;
    } else {

        return true;
    }

}

From source file:Main.java

public static Bitmap getBitmap(String path) {

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inSampleSize = 8;//  w  ww  .  j a v  a  2  s . co m

    return BitmapFactory.decodeFile(path, options);
}

From source file:Main.java

public static Options getBitmapOptions(String srcPath) {
    Options options = new Options();
    options.inJustDecodeBounds = true;/*from  www.  ja  v a  2s. com*/
    BitmapFactory.decodeFile(srcPath, options);
    options.inJustDecodeBounds = false;
    return options;
}

From source file:Main.java

public final static Options getBitmapOptions(String srcPath) {
    Options options = new Options();
    options.inJustDecodeBounds = true;/*from w w w .j a v  a 2  s . com*/
    BitmapFactory.decodeFile(srcPath, options);
    return options;
}

From source file:Main.java

public static Point getImageSize(String path) {
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;/*  ww w  . j  ava  2s . c o  m*/
    BitmapFactory.decodeFile(path, options);
    return new Point(options.outWidth, options.outHeight);
}

From source file:Main.java

public static Point getImageRawSize(String imagePath) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;//from   w w w  .j  a va 2s. c  o  m
    BitmapFactory.decodeFile(imagePath, options);
    return new Point(options.outWidth, options.outHeight);
}

From source file:Main.java

public static Bitmap decodeSampledBitmapFromFile(String path, int requiredWidth, int requiredHeight) {
    if (path == null) {
        return null;
    }/*www .ja  va2s  .  co  m*/
    Bitmap bmp = BitmapFactory.decodeFile(path, null);
    return Bitmap.createScaledBitmap(bmp, requiredWidth, requiredHeight, true);
}

From source file:Main.java

public static Bitmap decodeFile(String path) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    return BitmapFactory.decodeFile(path, options);
}

From source file:Main.java

private static BitmapFactory.Options getBitmapOptions(String path) {
    BitmapFactory.Options opts = new BitmapFactory.Options();
    opts.inJustDecodeBounds = true;//from  ww w.  ja  v  a2  s .c o  m
    BitmapFactory.decodeFile(path, opts);
    return opts;
}

From source file:Main.java

public static Pair<Integer, Integer> decodeDimensions(String path) {
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;/*from   ww  w.ja v a2 s.c o  m*/
    BitmapFactory.decodeFile(path, options);
    return Pair.create(options.outWidth, options.outHeight);
}