increase quality/clarity/brightness of the photos taken with android camera

I have an android app where I'm using the android camera in order to take photos.And after struglling a little bit I managed to have my picture where I want and how I want.The final problem is the quality of the image.

When my preview starts everything looks very clear and great but after taking the photo and showing the final result the image is not looking good at all.

Here is how my surfaceChanged() method looks like-where I'm setting some parameters:

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;
    }

Coudl someone tell what's the way to increase the quality of my photo.Thanks!

EDIT:

In activity A where the picture is taken I use a bundle to send the image to another activity B where I store it on the SDCARD.Here is how I do it:

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();

            }
        }
    };

in 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);

I receive the picture I put it in a bitmap, I rotate it and draw a text on it in the method drawTextImage() . After all this I store the bitmapResult on sdcard using this:

  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;
    }

I ussually call it like this: StoreByteImage(getBaseContext(),bitmapResult,100,String.valueOf(value)); Thanks

7
задан adrian 14 November 2013 в 21:26
поделиться