0

ネイティブカメラアプリを呼び出して写真を撮り、さらに操作するために画像を返すAndroidアプリがあります。私の問題は、カメラが2(+)メガピクセルに設定されていると、メモリリークが発生することです。理想的には、このアプリでは画質が問題にならないため、最低(VGA)に設定する必要があります。

アプリからネイティブデバイスのカメラアプリの設定を変更する方法はありますか?これが私が使用しているコードです:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            mImageCaptureUri = 
            Uri.fromFile(new file(Environment.getExternalStorageDirectory(),
            "fname_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri);

どんな助けでもいただければ幸いです。

4

1 に答える 1

0

残念ながら、写真を撮りたい画像の解像度をカメラアプリケーションに伝える方法はありません。

ただし、次のようなビットマップ機能にアクセスすることで、アプリで自分で何かを行うことができます(2番目のオプションの方がニーズに適しています)

  • ダウンサンプリング。サンプルサイズは1より大きくする必要があります。2と4を試してください。

    BitmapFactoryOptions.inSampleSize = sampleSize;

  • 元のビットマップから必要なサイズの新しいビットマップを作成します。

    // calculate the change in scale 
    float scaleX = ((float) newWidth_that_you_want) / originalBitmap.width();
    float scaleY = ((float) newHeight_that_you_want) / originalBitmap.height();
    
    // createa matrix for the manipulation
    Matrix matrix = new Matrix();
    matrix.postScale(scaleX , scaleY );
    
    Bitmap newBitmap = 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();
    
于 2011-09-08T13:52:52.983 に答える