加大与Android摄像头所拍摄的照片的质量/清晰度/亮度 [英] increase quality/clarity/brightness of the photos taken with android camera

查看:116
本文介绍了加大与Android摄像头所拍摄的照片的质量/清晰度/亮度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Android应用程序,其中我使用的是Android摄像头,以struglling一点点我设法把我的照片,我想以后采取photos.And,我怎么want.The最后一个问题是的质量图像。

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.

在我的preVIEW开始一切看起来非常清晰,伟大的,但采取的照片,并显示最终结果的图像不看差了之后。

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.

下面是我的 surfaceChanged()方法看起来像,在那里我设置一些参数:

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有人告诉什么是增加我的photo.Thanks质量的方法!

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

编辑:

活动A 在这里拍摄照片我用包将图像发送到另一 b活动其中,我将其存储在 SD卡。这里是我如何做到这一点:

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:

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

            }
        }
    };

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

我收到的图片我把它放在一个位图,我旋转和方法借鉴它的文本 drawTextImage()。 这一切后我店的 bitma presult SD卡使用这样的:

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

我ussually这样称呼它: StoreByteImage(getBaseContext(),bitma presult,100,将String.valueOf(值)); 谢谢

推荐答案

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

I had this issue because auto-focus was disabled.

你可以添加以下权限到你的Andr​​oid清单:

Try adding this permission to your Android Manifest:

 <uses-feature android:name="android.hardware.camera.autofocus" />

这篇关于加大与Android摄像头所拍摄的照片的质量/清晰度/亮度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆