提高用Android相机拍摄的照片的质量/清晰度/亮度

adr*_*ian 7 android photo

我有一个Android应用程序,我正在使用Android相机拍照.然后在一点点后,我设法让我的照片在我想要的地方和我想要的.最后的问题是图像的质量.

当我的预览开始时,一切都看起来非常清晰和伟大,但在拍摄照片并显示最终结果后,图像看起来并不好看.

以下是我的surfaceChanged()方法的样子 - 我在哪里设置一些参数:

public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        Log.e(TAG, "surfaceChanged");
        if (mPreviewRunning) {
            mCamera.stopPreview();
        }

        Camera.Parameters p = mCamera.getParameters();
        List<Size> sizes = p.getSupportedPictureSizes();

 System.out.println("Lista de parametrii este urmatoarea:"+sizes);
       Size   size = sizes.get(7);
      p.setPictureSize(size.width,size.height);
       mCamera.setParameters(p);
        try {
            mCamera.setPreviewDisplay(holder);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        mCamera.startPreview();
        mPreviewRunning = true;
    }
Run Code Online (Sandbox Code Playgroud)

Coudl有人告诉我提高照片质量的方法是什么.谢谢!

编辑:

activity A拍摄照片的地方,我使用一个束将图像发送到activity B我将其存储在另一个图像上.我SDCARD就是这样做的:

Activity A:

 Camera.PictureCallback mPictureCallback = new Camera.PictureCallback(){
        public void onPictureTaken(byte[] imageData, Camera c) {

            if (imageData != null) {

                Intent mIntent = new Intent();
                Bundle b = new Bundle();
                b.putByteArray("imageData", imageData);
                Intent i = new Intent(mContext,ImageDisplayActivity.class);
                i.putExtras(b);
                startActivity(i);

                setResult(FOTO_MODE, mIntent);
                finish();

            }
        }
    };
Run Code Online (Sandbox Code Playgroud)

activity B:

Bundle extras = getIntent().getExtras();
        BitmapFactory.Options options=new BitmapFactory.Options();
        options.inSampleSize = 5;
        byte[] imageData = extras.getByteArray("imageData");
        Bitmap myImage = BitmapFactory.decodeByteArray(imageData , 0, imageData.length,options);

       Matrix mat=new Matrix();
        mat.postRotate(90);
        bitmapResult = Bitmap.createBitmap(myImage, 0, 0,  myImage.getWidth(),myImage.getHeight(), mat, true); 

        Canvas c = new Canvas(bitmapResult);
        drawTextImage(bitmapResult);
Run Code Online (Sandbox Code Playgroud)

我收到我把它放在位图中的图片,我旋转它并在方法中绘制文本drawTextImage().这一切后我存储bitmapResultsdcard使用这样的:

  public static boolean StoreByteImage(Context mContext, Bitmap bitmap, int quality, String expName) {


        FileOutputStream fileOutputStream = null;
        String extStorageDirectory=Environment.getExternalStorageDirectory().toString();
        File myNewFolder = new File(extStorageDirectory + newFolder);
        if(myNewFolder.mkdirs())
        {
        myNewFolder.mkdir();
        }
        try {     

            //fileOutputStream = new FileOutputStream(sdImageMainDirectory.toString() +"/image.jpg");
            fileOutputStream = new FileOutputStream(myNewFolder +"/"+expName+".jpg");
            BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);

            bitmap.compress(CompressFormat.JPEG, quality, bos);

            bos.flush();
            bos.close();

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return true;
    }
Run Code Online (Sandbox Code Playgroud)

我通常称之为:StoreByteImage(getBaseContext(),bitmapResult,100,String.valueOf(value)); 谢谢

b_y*_*yng 0

我遇到这个问题是因为自动对焦被禁用。

尝试将此权限添加到您的 Android 清单中:

 <uses-feature android:name="android.hardware.camera.autofocus" />
Run Code Online (Sandbox Code Playgroud)