不能'保存图像的最大分辨率从相机意图

问题描述:

我正在打开相机意图,并试图将图像保存到SD卡中的文件夹。我可以拍摄图像,图像得到保存。不能'保存图像的最大分辨率从相机意图

但问题是获取存储缩略图分辨率图像(160 * 120)大小的图像。

这是我在做什么...

要打开相机

mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    mIntent.putExtra(MediaStore.EXTRA_OUTPUT, 
      MediaStore.Images.Media.EXTERNAL_CONTENT_URI 
        .toString()); 
    mIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); 
    startActivityForResult(mIntent, PHOTO_SELECT); 

而且对结果活动...

imageFileFolder = new File(Environment.getExternalStorageDirectory(), 
      "MyApp"); 
    FileOutputStream out = null; 
    Calendar c = Calendar.getInstance(); 
    String date = fromInt(c.get(Calendar.MONTH)) 
      + fromInt(c.get(Calendar.DAY_OF_MONTH)) 
      + fromInt(c.get(Calendar.YEAR)) 
      + fromInt(c.get(Calendar.HOUR_OF_DAY)) 
      + fromInt(c.get(Calendar.MINUTE)) 
      + fromInt(c.get(Calendar.SECOND)); 
    imageFileName = new File(imageFileFolder, date.toString() + ".jpg"); 

    try 
    { 
     out = new FileOutputStream(imageFileName); 
     bmp.compress(Bitmap.CompressFormat.JPEG, 100, out); 
     out.flush(); 
     out.close(); 
     scanPhoto(imageFileName.toString()); 
     out = null; 

谁能请在存储高帮分辨率的图像,我正在采取...

+0

为什么您使用EXTRA_VIDEO_QUALITY照片? – Reno 2011-02-23 06:55:51

+0

只是给了它一个镜头。该代码没有任何区别。 – 2011-02-23 06:59:54

我想你使用下面的类捕获图像我T的保存图像和图像分辨率 取决于你的相机MP ...可能是对..

public class CameraApplication extends Activity implements 
     SurfaceHolder.Callback { 
    private static final String TAG = "cookbook.hardware"; 
    private LayoutInflater mInflater = null; 
    Camera mCamera; 
    byte[] tempdata; 
    boolean mPreviewRunning = false; 
    private SurfaceHolder mSurfaceHolder; 
    private SurfaceView mSurfaceView; 
    Button takepicture; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
    getWindow().setFormat(PixelFormat.TRANSLUCENT); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
      WindowManager.LayoutParams.FLAG_FULLSCREEN); 

    setContentView(R.layout.main); 

    mSurfaceView = (SurfaceView) findViewById(R.id.surface); 

    mSurfaceHolder = mSurfaceView.getHolder(); 
    mSurfaceHolder.addCallback(this); 
    mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); 

    mInflater = LayoutInflater.from(this); 

    View overView = mInflater.inflate(R.layout.cameraoverlay, null); 
    this.addContentView(overView, new LayoutParams(
      LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 

    takepicture = (Button) findViewById(R.id.button); 

    takepicture.setOnClickListener(new OnClickListener() { 
     public void onClick(View view) { 
      mCamera.takePicture(mShutterCallback, mPictureCallback, mjpeg); 
     } 
    }); 
} 

ShutterCallback mShutterCallback = new ShutterCallback() { 
    @Override 
    public void onShutter() { 
    } 
}; 
PictureCallback mPictureCallback = new PictureCallback() { 
    public void onPictureTaken(byte[] data, Camera c) { 
    } 
}; 
PictureCallback mjpeg = new PictureCallback() { 
    public void onPictureTaken(byte[] data, Camera c) { 
     if (data != null) { 
      tempdata = data; 
      done(); 
     } 
    } 
}; 

void done() { 
    Bitmap bm = BitmapFactory.decodeByteArray(tempdata, 0, tempdata.length); 
    String url = Images.Media.insertImage(getContentResolver(), bm, null, 
      null); 
    bm.recycle(); 
    Bundle bundle = new Bundle(); 
    if (url != null) { 
     bundle.putString("url", url); 
     Intent mIntent = new Intent(); 
     mIntent.putExtras(bundle); 
     setResult(RESULT_OK, mIntent); 
    } else { 
     Toast 
       .makeText(this, "Picture can not be saved", 
         Toast.LENGTH_SHORT).show(); 
    } 
    finish(); 
} 

@Override 
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { 
    Log.e(TAG, "surfaceChanged"); 
    try { 
     if (mPreviewRunning) { 
      mCamera.stopPreview(); 
      mPreviewRunning = false; 
     } 
     Camera.Parameters p = mCamera.getParameters(); 
     p.setPreviewSize(w, h); 
     mCamera.setParameters(p); 
     mCamera.setPreviewDisplay(holder); 
     mCamera.startPreview(); 
     mPreviewRunning = true; 
    } catch (Exception e) { 
     Log.d("", e.toString()); 
    } 
} 

@Override 
public void surfaceCreated(SurfaceHolder holder) { 
    Log.e(TAG, "surfaceCreated"); 
    mCamera = Camera.open(); 
} 

@Override 
public void surfaceDestroyed(SurfaceHolder holder) { 
    Log.e(TAG, "surfaceDestroyed"); 
    mCamera.stopPreview(); 
    mPreviewRunning = false; 
    mCamera.release(); 
    mCamera = null; 
} 
} 

main.xml中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:orientation="vertical"> 
    <SurfaceView android:id="@+id/surface" 
     android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    </SurfaceView> 
</LinearLayout> 

cameraoverlay.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:orientation="vertical" android:gravity="bottom" 
    android:layout_gravity="bottom"> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" android:layout_height="wrap_content" 
     android:orientation="horizontal" android:gravity="center_horizontal"> 
     <Button android:id="@+id/button" android:layout_width="wrap_content" 
      android:layout_height="wrap_content" android:text="take picture" /> 
    </LinearLayout> 
</LinearLayout> 

和不忘记相机用户权限

<uses-permission android:name="android.permission.CAMERA"></uses-permission> 

可能在您的应用程序中工作....