Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save Image captured temporary on Android

Tags:

android

opencv

I am developing an Android Application that captures an image then processes it using opencv functions, then returns the resulting image and displays it in image view. How can I save the captured image temporarily in order to process it?

public class Camera extends Activity 
{
    ImageView imgview;
    Bitmap Bmp;
    final static int cameraData=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.camera);
         imgview= (ImageView) findViewById(R.id.imgview);
        Intent i=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

        startActivityForResult(i,cameraData);
    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // TODO Auto-generated method stub
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode == RESULT_OK)
        {
            Bundle extras=data.getExtras();
            Bmp=(Bitmap)extras.get("data");
            imgview.setImageBitmap(Bmp);
        }
    }
}
like image 918
QAIS Avatar asked Oct 25 '25 14:10

QAIS


1 Answers

You can save the bitmap to the cache folder of the application as follows:

String destFolder = getCacheDir().getAbsolutePath();

FileOutputStream out = new FileOutputStream(destFolder + "/myBitamp.png");
bmp.compress(Bitmap.CompressFormat.PNG, 100, out);
like image 157
Marcin S. Avatar answered Oct 28 '25 03:10

Marcin S.