Skip to content Skip to sidebar Skip to footer

Change Camera Settings From Another App's Activity

I have an Android app that calls the native camera app to take a picture and returns the image for further manipulation. My problem, is that I run into memory leaks if the camera i

Solution 1:

Unfortunately there is no way of telling the camera application what picture resolution you want to take the picture at.

But you can however do something about it yourself in your app by acesssing some bitmap functionalities like (2nd option would be more suited for your needs)

  • Downsampling. Sample size should be greater than 1. Try 2 and 4.

    BitmapFactoryOptions.inSampleSize = sampleSize;

  • Creating a new bitmap with the size that you require from the original bitmap..

    // calculate the change in scale floatscaleX= ((float) newWidth_that_you_want) / originalBitmap.width();
    floatscaleY= ((float) newHeight_that_you_want) / originalBitmap.height();
    
    // createa matrix for the manipulationMatrixmatrix=newMatrix();
    matrix.postScale(scaleX , scaleY );
    
    BitmapnewBitmap= Bitmap.createBitmap(originalBitmap, 0, 0, width, height, matrix, true);
    //since you don't need this bitmap anymore, mark it so that GC can reclaim it.//note: after recycle you should not use the originalBitmap object anymore.//if you do then it will result in an exception.
    originalBitmap.recycle();
    

Post a Comment for "Change Camera Settings From Another App's Activity"