LoginSignup
5
6

More than 5 years have passed since last update.

Android、画像ファイルからBitmapを生成する方法 + おまけ

Posted at

カメラで撮影した写真をグリッドビューで表示するための下調べメモです。

画像ファイルをBitmapへ

Bitmap bm = BitmapFactory.decodeFile(pathName);

pathName:Bitmapにしたい画像ファイルのパス

あるディレクトリ内のファイルパス一覧の取得方法

File[] files = new File(directoryPath).listFiles();
List<String> pathList = new ArrayList<String>();
for(File file : files){
    pathList.add( file.getPath() );
}

directoryPath:ディレクトリのパス
File.listFiles(): ディレクトリ内のファイル一覧をFileクラスのオブジェクト配列として返す
File.getPath(): ファイルのパス(相対パス)を取得する

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6