android 摄像头拍照获取的图片设置质量,android – 如何提高CameraManager拍摄的照片质量...

These are some methods when we working on Camer manager,this method

may help you.

Android Camera应用程序对Intent中的照片进行编码

传递给onActivityResult()作为附加内容中的一个小位图

关键的“数据”.以下代码检索此图像并显示

它在ImageView中.

@Override

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

if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {

Bundle extras = data.getExtras();

Bitmap imageBitmap = (Bitmap) extras.get("data");

mImageView.setImageBitmap(imageBitmap);

}

}

private File createImageFile() throws IOException {

// Create an image file name

String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());

String imageFileName = "JPEG_" + timeStamp + "_";

File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);

File image = File.createTempFile(

imageFileName, /* prefix */

".jpg", /* suffix */

storageDir /* directory */

);

// Save a file: path for use with ACTION_VIEW intents

mCurrentPhotoPath = "file:" + image.getAbsolutePath();

return image;

}

private void setPic() {

// Get the dimensions of the View

int targetW = mImageView.getWidth();

int targetH = mImageView.getHeight();

// Get the dimensions of the bitmap

BitmapFactory.Options bmOptions = new BitmapFactory.Options();

bmOptions.inJustDecodeBounds = true;

BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);

int photoW = bmOptions.outWidth;

int photoH = bmOptions.outHeight;

// Determine how much to scale down the image

int scaleFactor = Math.min(photoW/targetW, photoH/targetH);

// Decode the image file into a Bitmap sized to fill the View

bmOptions.inJustDecodeBounds = false;

bmOptions.inSampleSize = scaleFactor;

bmOptions.inPurgeable = true;

Bitmap bitmap = BitmapFactory.decodeFile(mCurrentPhotoPath, bmOptions);

mImageView.setImageBitmap(bitmap);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值