将相机尺寸 - 参数VS意图是什么? [英] Set Camera Size - Parameters vs Intent?

查看:100
本文介绍了将相机尺寸 - 参数VS意图是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的意图,拍摄照片,像这样的:

I am currently using an intent to take a picture, like this:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
intent.putExtra("return-data", true);
startActivityForResult(intent, CAMERA_REQUEST);

但我真的需要设置图像大小接近正方形的可能。因此,研究后,似乎你需要做的是这样的:

But I really need to set the image size as close to a square as possible. So after researching it seems you need to do something like this:

Camera camera = Camera.open();
Parameters params = camera.getParameters();
List<Camera.Size> sizes = params.getSupportedPictureSizes();

// Once you will see the supported Sizes, you can define them with the method :

setPictureSize(int width, int height);

我的问题是,做这些工作的同时还是一个要么/或?哪种方法最适合我的需要?

My questions are, do these work together or is it an either/or? Which method works best for my needs?

此外,我还通过96PX框的用户配置文件图片96PX。用户拍摄照片后,我想要的图像,以填补整个箱体无拉伸。是在画面的点集大小上当受骗,或改变的ImageView 位图(或最佳方式。 ..事后?)?或者,我应该只是让用户裁剪图片,我可以定义裁剪区域的尺寸?

Again, I have 96px by 96px box for user profile pics. After user takes the picture I want the image to fill entire box without stretching. Is the best way to set size at the point of picture being taken, or alter the imageView or bitmap (or ...?) after the fact? OR, should I just let the users crop the picture and I can define the cropping area dimensions?

编辑:见赏金更新的问题

推荐答案

这code允许我从画廊挑选图像。作物,用我的纵横比。我也做了类似$ C $下使用相机。用户需要的图片后,它会立即启动一项活动,以裁剪图片。

This code allows me to pick image from gallery. Crop and use my aspect ratio. I did similar code for using camera. After user takes picture, it immediately launches an activity to crop the picture.

  Intent photoPickerIntent = new Intent(
                        Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                photoPickerIntent.setType("image/*");
                photoPickerIntent.putExtra("crop", "true");
                photoPickerIntent.putExtra("outputX", 150);
                photoPickerIntent.putExtra("outputY", 150);
                photoPickerIntent.putExtra("aspectX", 1);
                photoPickerIntent.putExtra("aspectY", 1);
                photoPickerIntent.putExtra("scale", true);
                photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
                photoPickerIntent.putExtra("outputFormat",
                        Bitmap.CompressFormat.JPEG.toString());
                startActivityForResult(photoPickerIntent, RESULT_LOAD_IMAGE);

这篇关于将相机尺寸 - 参数VS意图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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