拍摄照片后,程序会自动返回onBackPressed()
。
当我删除putExtra时,意图运行。当我在startActivity()
之后放置takePicture()
时,它会传输空数据....
我只是想将图像数据放到另一个活动中以便其他用途。如何实现?
private PictureCallback picture = new PictureCallback(){
@Override
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
Intent intent = new Intent(CameraFilming.this, PhotoPreview.class);
intent.putExtra("imageByte", data); //Picture data transfer to next activity
startActivity(intent);
}
};
//take photo by pressing button
private class captureBtnListener implements View.OnClickListener{
@Override
public void onClick(View v){
capture.setOnClickListener(null);
CountDownTimer timer = new CountDownTimer(10000, 1000){
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
countdown.setText(millisUntilFinished/1000+"");
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
countdown.setText("0");
camera.takePicture(null, null, picture);
}
};
timer.start();
}
}
public class PhotoPreview extends Activity{
private RelativeLayout layout;
private ImageView overlay, texture, face1, face2;
@Override
public void onCreate (Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.photo_preview);
layout = (RelativeLayout)findViewById(R.id.preview_layout);
byte[] data = getIntent().getByteArrayExtra("imageByte");
if (data == null){
Log.d("PhotoPreview", "no image data");
finish();
}
Bitmap rawPhotoBitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
ImageProcess imgProcess = new ImageProcess(this);
Bitmap resizedFace = imgProcess.scaleAccordingWidth(imgProcess.cropImage(rawPhotoBitmap, 840, 125, 440, 560), 77);
face1 = new ImageView(this);
face1.setImageBitmap(resizedFace);
Log.d("testing", "testing");
}
}