캡처 한 .bmp 파일을 sdcard에 저장하려고합니다. 다음은 이에 대한 책임이 코드 조각입니다 :안드로이드 저장 bmp 이미지
String root = Environment.getExternalStorageDirectory().toString();
File mFolder = new File(root + "/mFolder");
if (!mFolder.exists())
{
mFolder.mkdir();
}
String strF = mFolder.getAbsolutePath();
File mSubFolder = new File(strF + "/MyApp-SubFolder");
if (!mSubFolder.exists())
{
mSubFolder.mkdir();
}
String s = "myfile.png";
File f = new File(mSubFolder.getAbsolutePath(),s);
String strMyImagePath = f.getAbsolutePath();
FileOutputStream fos = null;
try
{
fos = new FileOutputStream(f);
bmp.compress(Bitmap.CompressFormat.PNG,70, fos);
fos.flush();
fos.close();
Log.d("asd", "yeah!");
// MediaStore.Images.Media.insertImage(getContentResolver(), b, "Screen", "screen");
}catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
는하지만 오류가 :
images are invalid and its size are 0kb
내가 잘못하고있는 중이 야 무슨 일이?
문자열의 = "myfile.png"; ? 당신은 파일이 – Hasham
이 \t 파일 storagePath = 새로운 파일 ( \t \t \t \t \t Environment.getExternalStorageDirectory() + "/ MyApp를-하위 폴더 /") 시도 .BMP이고; – Hasham