本文介绍了低画面/图像质量时,从相机捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。当我尝试从相机获取的图片,质量是非常低的。首先,利用摄像头捕捉的画面,比保存的目录,并在同一时间得到的图片,并显示在保存的目录里面我app.The图片是一个优良的品质,但是当我从目录中得到它,质量不高。下面是我的示例code:

I have one problem. When I try to get picture from camera, the quality is very low.At first, capture the picture using camera, than save to the directory and at the same time get that picture and show in my app.The picture saved inside directory is a fine quality but when I get it from directory, the quality is low. below is my sample code :

public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    if (requestCode == CAMERA_PIC_REQUEST) {

        Bitmap thumbnail = (Bitmap) intent.getExtras().get("data");

        if (g==1)
        {
            ImageView myImage = (ImageView) findViewById(R.id.img5);
            myImage.setImageBitmap(thumbnail);

            View a = findViewById(R.id.img5);
            a.setVisibility(View.VISIBLE);

            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, stream);

            byteArray1 = stream.toByteArray();
        }
}

任何解决方案/建议吗?感谢:)

any solution/suggestion?Thanks :)

解决

当我遵循 Antrromet 下面给出

推荐答案

我使用了下列code和这工作完全正常的我。

I have used the following code and this works perfectly fine for me.

            values = new ContentValues();
            values.put(MediaStore.Images.Media.TITLE, "New Picture");
            values.put(MediaStore.Images.Media.DESCRIPTION, "From your Camera");
            imageUri = getContentResolver().insert(
                    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
            startActivityForResult(intent, PICTURE_RESULT);

和也

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {

        case PICTURE_RESULT:
            if (requestCode == PICTURE_RESULT)
                if (resultCode == Activity.RESULT_OK) {
                    try {
                        thumbnail = MediaStore.Images.Media.getBitmap(
                                getContentResolver(), imageUri);
                        imgView.setImageBitmap(thumbnail);
                        imageurl = getRealPathFromURI(imageUri);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
        }
    }

public String getRealPathFromURI(Uri contentUri) {
        String[] proj = { MediaStore.Images.Media.DATA };
        Cursor cursor = managedQuery(contentUri, proj, null, null, null);
        int column_index = cursor
                .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        return cursor.getString(column_index);
    }

这篇关于低画面/图像质量时,从相机捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 16:35