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) 

Source Link

Document

Decode a file path into a bitmap.

Usage

From source file:Main.java

public static Bitmap File2Bitmap(File file) {
    if (file != null) {
        return BitmapFactory.decodeFile(file.getAbsolutePath());
    } else {//from  w ww. ja v a 2 s. co m
        return null;
    }
}

From source file:Main.java

public static Bitmap getBitmapFromFile(@NonNull String path) {
    return BitmapFactory.decodeFile(path);
}

From source file:Main.java

public static Bitmap createBitmap(String paramString, int paramInt1, int paramInt2) {

    Bitmap localBitmap1 = BitmapFactory.decodeFile(paramString);
    Bitmap localBitmap2 = null;/*from w w w .ja va 2 s. c  o m*/

    if (localBitmap1 != null) {
        localBitmap2 = Bitmap.createScaledBitmap(localBitmap1, paramInt1, paramInt2, true);
        localBitmap1.recycle();
    }

    return localBitmap2;
}

From source file:Main.java

public static Bitmap getBitmap(String paramString) {
    if (new File(paramString).exists())
        return BitmapFactory.decodeFile(paramString);
    return null;/*w ww  . j  a v a 2  s.  c om*/
}

From source file:Main.java

public static Bitmap getBitmapFromFile(String url) {
    return BitmapFactory.decodeFile(CACHES_PATH + url + ".png");
}

From source file:Main.java

public static Bitmap cutImage(RectF rect, String imagePath) {
    Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
    return cropImage(rect, bitmap);

}

From source file:Main.java

public static String simpleCompressImage(String path, String newPath) {
    Bitmap bitmap = BitmapFactory.decodeFile(path);
    FileOutputStream outputStream = null;
    try {//from  w w w .  j  ava2 s .c om
        outputStream = new FileOutputStream(newPath);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 80, outputStream);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    recycle(bitmap);
    return newPath;
}

From source file:Main.java

/**
 * Get image from the given path//from w  w w.j a v  a  2 s.c om
 * @param path
 * @return
 */
public static Bitmap getImageFromPath(String path) {
    return BitmapFactory.decodeFile(path);
}

From source file:Main.java

public static Bitmap getBitmap(String aPath) {
    Bitmap bmp = null;//from  www  .j  a  v a2 s. co m
    try {
        bmp = BitmapFactory.decodeFile(aPath);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return bmp;
}

From source file:Main.java

public static byte[] path2Bytes(String path) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BitmapFactory.decodeFile(path).compress(Bitmap.CompressFormat.PNG, 100, baos);
    return baos.toByteArray();
}