AndroidCameraIntentを使用して画像をキャプチャしようとしています。カメラインテントはバイト配列を返し、バイト配列をビットマップとして保存すると、現在のカメラ設定(現在Androidモバイルカメラに設定されている1024ピクセル)に基づいて画像を取得する代わりに、非常に小さい画像を取得しています。
通常、カメラインテントからファイルパスを取得しますが、どういうわけかこのデバイスから取得していないため、カメラインテントから返されたバイトからビットマップを作成しています。
これがなぜであり、この問題を解決する方法を誰もが知っています。ありがとう。
以下は私が使用しているJavaコードブロックです。
プライベートインテントcameraIntent=null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_PIC_REQUEST) {
if (resultCode == RESULT_OK) {
if ( data != null)
{
Bitmap myImage = null;
Bitmap imageBitmap = (Bitmap) data.getExtras().get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100,stream);
byte[] byteArray = stream.toByteArray();
BitmapFactory.Options options = new BitmapFactory.Options();
myImage = BitmapFactory.decodeByteArray(byteArray, 0,byteArray.length, options);
fileOutputStream = new FileOutputStream(sPath);
BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
myImage.compress(CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
}
}
}
}