Tôi đang phát triển một ứng dụng trong đó người dùng sẽ chụp Ảnh từ máy ảnh và hiển thị nó trên màn hình xem trước có chế độ xem hình ảnh.Thanh tiến trình Android trên ImageView
**CameraCapture.java**
class ButtonClickHandler implements View.OnClickListener
{
public void onClick(View view){
myVib.vibrate(50);
startCameraActivity();
}
}
protected void startCameraActivity()
{
File filenew = new File(_path);
Uri outputFileUri = Uri.fromFile(filenew);
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivityForResult(intent, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
switch(resultCode)
{
case 0:
break;
case -1:
//pictaken++;
onPhotoTaken();
break;
}
}
protected void onPhotoTaken()
{
//pictaken=true;
Intent i = new Intent(CameraCapture.this,Preview.class);
startActivity(i);
}
Trong lớp Preview của tôi hình ảnh chụp được hiển thị trên ImageView
**Preview.java**
File imgFile = new File("/sdcard/DCIM/Camera/test.jpg");
if(imgFile.exists()){
// Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
ImageView myImage = (ImageView) findViewById(R.id.image);
Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
Matrix mat = new Matrix();
String degree="90";
mat.postRotate(Integer.parseInt(degree));
Bitmap bMapRotate = Bitmap.createBitmap(myBitmap, 0, 0,myBitmap.getWidth(),myBitmap.getHeight(), mat, true);
myImage.setImageBitmap(bMapRotate);
//myImage.setImageBitmap(myBitmap);
}
_image = (ImageView) findViewById(R.id.image);
Có cách nào để hiển thị thanh tiến trình trên ImageView cho đến khi nó tải hình ảnh chụp từ thẻ SD. Thnx trước :)
tuyệt vời, nhưng cách nhận thông báo khi hình ảnh được tải? –