Android Bitmap Load loadImage(String filename)

Here you can find the source of loadImage(String filename)

Description

Load an image

License

Open Source License

Parameter

Parameter Description
filename The filename

Return

The bitmap

Declaration

public static Bitmap loadImage(String filename) 

Method Source Code

/* Copyright (c) 2010-2014 ARTags Project owners (see http://www.artags.org)
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.//  w  ww .  j  av a2 s. c o m
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Matrix;
import android.os.Environment;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import org.artags.android.app.apilevels.ApiLevel4;
import org.artags.android.app.apilevels.ApiLevels;

public class Main{
    private static final String ROOT_DIRECTORY = "/ARTags";
    /**
     * Load an image
     * @param filename The filename
     * @return The bitmap
     */
    public static Bitmap loadImage(String filename) {
        File root = Environment.getExternalStorageDirectory();
        try {
            File directory = new File(root.getPath() + ROOT_DIRECTORY);
            String filepath = directory.getPath() + "/" + filename;
            Options option = new Options();
            if (ApiLevels.getApiLevel() >= 4) {
                //option.inScaled = false;
                option = ApiLevel4.setInScaled(option, false);
            }
            return BitmapFactory.decodeFile(filepath, option);

        } catch (Exception e) {
            Log.e("ARTags:BitmapUtil:saveImage",
                    "Exception while loading the tag", e);
        }
        return null;
    }
}

Related

  1. loadBitmap(String url)
  2. loadBitmap(String url)
  3. loadBitmapAsset(Context context, String asset)
  4. loadBitmapFromAssets(Context context, String name)
  5. loadBitmapFromStorage(String path)
  6. loadImage(String urlStr)
  7. loadPreviewBitmap(String fileName, int width, int height)
  8. SafeDecodeBitmapFile( String strFilePath)
  9. decodeF(File f)