Android:从相机捕获的裁剪图像中的宽高比

时间:2022-08-27 10:46:02

Can we provide aspect ratio for the image captured from camera that is cropped at runtime.so for the parameter

我们是否可以为在运行时裁剪的相机捕获的图像提供纵横比。对于参数

1.intent.putExtra("crop","true");      works
2.intent.putExtra("aspectX",730);      not working
3.intent.putExtra("aspectY",1115);     not working
4.intent.putExtra("outputX",730);      not working
5.intent.putExtra("outputY",1115);     not working

:While it is working for the image taken from gallery

:虽然它适用于从画廊拍摄的图像

Is this the way to provide aspect ratio or not for image captured by camera activity?I need your help? Thanks

这是为相机活动拍摄的图像提供宽高比的方式吗?我需要你的帮助吗?谢谢

UPDATE--> CODE

更新 - >代码

public void onClick(DialogInterface dialog, int item)
                {
                    Intent intent = new Intent();
                    intent.putExtra("crop", "true"); 
                    intent.putExtra("aspectX", 730);
                    intent.putExtra("aspectY", 735);
                    intent.putExtra("outputX", 730);
                    intent.putExtra("outputY", 735);

                    if(item==0)
                    {
                        intent.setAction("android.media.action.IMAGE_CAPTURE");
                        startActivityForResult(intent, PICK_FROM_CAMERA);
                    }

1 个解决方案

#1


0  

try this code;

试试这段代码;

intent.putExtra("crop","true");      
intent.putExtra("aspectX",3);      
intent.putExtra("aspectY",4);     
intent.putExtra("outputX",730);     
intent.putExtra("outputY",1115);

but i think intent.putExtra("outputY",1115); is not possible because 1115 height may not be possible.

但我认为intent.putExtra(“outputY”,1115);是不可能的,因为可能无法达到1115的高度。

#1


0  

try this code;

试试这段代码;

intent.putExtra("crop","true");      
intent.putExtra("aspectX",3);      
intent.putExtra("aspectY",4);     
intent.putExtra("outputX",730);     
intent.putExtra("outputY",1115);

but i think intent.putExtra("outputY",1115); is not possible because 1115 height may not be possible.

但我认为intent.putExtra(“outputY”,1115);是不可能的,因为可能无法达到1115的高度。