'SAVE'에 해당되는 글 1

  1. 2015.01.29 비트맵을 이미지파일로 저장하는 방법(Bitmap to file) 1

펌 OK (출처 표시), 상업적 이용 NO, 컨텐츠 변경 NO



비트맵, 파일이 저장될 경로, 저장할 파일명을 넘겨받아서


JPEG 파일로 저장하는 방법이다.


public static void SaveBitmapToFileCache(Bitmap bitmap, String strFilePath, String filename) {


File file = new File(strFilePath);


if (!file.exists())

file.mkdirs();


File fileCacheItem = new File(strFilePath + filename);

OutputStream out = null;


try {

fileCacheItem.createNewFile();

out = new FileOutputStream(fileCacheItem);


bitmap.compress(CompressFormat.JPEG, 100, out);

} catch (Exception e) {

e.printStackTrace();

} finally {

try {

out.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}