0
내 앱에서 사진을 찍어 그 사진을 사용하도록하려고합니다. 그러나 에뮬레이터와 Nexus One 모두에서 예외가 발생합니다. 하여 onActivityResult에서Android decodeBitmap with ACTION_IMAGE_CAPTURE
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(temporaryCameraFile));
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
()
if(resultCode == RESULT_OK){
Bitmap cameraPicture = decodeFile(temporaryCameraFile);
// resize to fit screen and add to queue to be drawn
if (cameraPicture != null)
if ((cameraPicture.getWidth() > 0) && (cameraPicture.getHeight() > 0))
page.SetBackground(ResizeImageToFit(cameraPicture));
}
decodeFile()
:private File temporaryCameraFile = new File("/sdcard/tmp.bmp");
가 사진을 촬영하기 위해 메뉴에서 선택 : 여기
내 코드입니다private Bitmap decodeFile(File f){
try {
//decode image size
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(new FileInputStream(f),null,o);
//decode with inSampleSize
o.inJustDecodeBounds = false;
Bitmap retval = BitmapFactory.decodeStream(new FileInputStream(f), null, o);
return retval;
} catch (FileNotFoundException e) {
Log.e("decodeFile()", e.toString());
return null;
}
}
decodeFile()에서 첫 번째 디코딩은 바운드를 제대로 반환합니다. 그러나 두 번째로 호출하면 에뮬레이터와 Nexus One 모두에서 다음 오류가 발생합니다. injustDecodeBounds 메서드없이 주 디코드 만 수행하도록 decodeFile을 업데이트하려고 시도했지만 실패했습니다. 또한, 나는 수동으로 장치의 파일을 꺼냈다 그것은 유효한 비트 맵입니다.
09-20 15:30:58.711: ERROR/AndroidRuntime(332): Caused by: java.lang.IllegalArgumentException: width and height must be > 0
어떤 도움을 주시면 감사하겠습니다.
감사합니다.