私はアプリ内カメラを実装しており、写真を撮るたびに画像は320x240になりますが、携帯電話のカメラははるかに高い解像度に対応しています(GalaxyNexus)。解像度を設定するためのパラメータが見つかりませんでした。撮影している画像の解像度を上げるにはどうすればよいですか?関連するコードは次のとおりです。
@Override
public void surfaceCreated( SurfaceHolder holder ) {
setSurfaceHolder( holder );
}
@Override
public void surfaceDestroyed( SurfaceHolder holder ) {
setSurfaceHolder( null );
}
private void attachCameraToSurface( Camera camera, SurfaceHolder holder ) {
try {
camera.setPreviewDisplay( holder );
setInPreview( true );
}
catch (IOException e) {
Log.e( "CameraFragment", "Exception in attachCameraToSurface()", e );
}
}
@Override
public void surfaceChanged( SurfaceHolder holder, int format, int width, int height ) {
Camera camera = getCamera();
if ( camera == null ) {
return;
}
Camera.Size size = getCameraPreviewSize( camera );
Camera.Parameters params = camera.getParameters();
params.setPreviewSize( size.width, size.height );
camera.setParameters( params );
attachCameraToSurface( camera, holder );
startPreview();
}
private Camera.Size getCameraPreviewSize( Camera camera ) {
Camera.Parameters params = camera.getParameters();
List<Camera.Size> supportedSizes = params.getSupportedPreviewSizes();
Rect frame = getSurfaceHolder().getSurfaceFrame();
int width = frame.width();
int height = frame.height();
for (Camera.Size size : supportedSizes) {
if ( size.width >= width || size.height >= height ) {
return size;
}
}
return supportedSizes.get( 0 );
}
@Override
public void onClick( View v ) {
switch (v.getId()) {
case R.id.camera_action_ImageView:
getCamera().takePicture( getShutterCallback(), null, new JpegPictureCallback() );
break;
}
}
private class JpegPictureCallback implements PictureCallback {
@Override
public void onPictureTaken( byte[] data, Camera camera ) {
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeByteArray( data, 0, data.length );
}
catch (OutOfMemoryError e) {
Log.e( "CameraFragment", "Out of memory decoding image from camera.", e );
return;
}
data = null;
if ( bitmap != null ) {
new SavePictureWorker( getActivity() ).execute( bitmap );
}
startPreview();
}
}