相机影像品质很差 [英] Very bad camera image quality
本文介绍了相机影像品质很差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将相机拍摄的图像保存到手机中.它可以工作,但是图像质量很差. 首先,出于意图,这是我的代码:
I'm trying to save image taken from camera in my phone. It works but the quality of images is very bad. First, for the intent, this is my code :
intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAMERA_REQUEST);
为了获得吸引力,我尝试了此方法:
And for ativity result, I tried this :
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_PICTURE)
{
if (resultCode == RESULT_OK)
{
bitmap = (Bitmap) data.getExtras().get("data");
String path = Images.Media.insertImage(getContentResolver(), bitmap, "", null);
Uri imageUri = Uri.parse(path);
}
您能帮我解决这个问题吗?
Can you please help me to resolve this problem ?
推荐答案
如果要将图像存储在磁盘上,请让Camera应用程序执行.在Intent
上添加EXTRA_OUTPUT
Uri
,指向要在其中存储图像的位置.
If you want the image to be on disk, let the camera app do it. Add an EXTRA_OUTPUT
Uri
to your Intent
, pointing to where you want the image to be stored.
package com.commonsware.android.camcon;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import java.io.File;
public class CameraContentDemoActivity extends Activity {
private static final int CONTENT_REQUEST=1337;
private File output=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent i=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File dir=
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
output=new File(dir, "CameraContentDemo.jpeg");
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(output));
startActivityForResult(i, CONTENT_REQUEST);
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == CONTENT_REQUEST) {
if (resultCode == RESULT_OK) {
Intent i=new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(output), "image/jpeg");
startActivity(i);
finish();
}
}
}
}
(来自此示例项目)
Uri
需要指向相机应用可以写的地方,例如外部存储.
The Uri
needs to point to a place where the camera app can write, such as external storage.
这篇关于相机影像品质很差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文