【问题标题】:Android:Aspect ratio in cropped image captured from cameraAndroid:从相机捕获的裁剪图像中的纵横比
【发布时间】:2011-10-18 18:51:35
【问题描述】:

我们能否为从相机捕获的在运行时裁剪的图像提供纵横比。so 为参数

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

:当它适用于从图库中获取的图像时

这是为相机活动捕获的图像提供纵横比的方法吗?我需要你的帮助吗? 谢谢

更新-->代码

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);
                    }

【问题讨论】:

  • 你运行的是哪个版本的android
  • 哦!抱歉,android sdk 2.1 不支持在相机中裁剪。
  • 你确定吗?那么它支持哪个版本?
  • 我已经在 2.3 中尝试过,但没有工作
  • 你能发布你的相机意图代码吗?

标签: android android-sdk-2.1 aspect-ratio


【解决方案1】:

试试这个代码;

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

但我认为 intent.putExtra("outputY",1115); 是不可能的,因为 1115 高度可能是不可能的。

【讨论】:

  • 嗨,试试你在 sdk 2.2 版本中的代码,相机裁剪肯定会工作。
  • 确保相机裁剪在 android 2.1 中不起作用。但是画廊图像裁剪肯定会起作用。因为相机使用一个类名进行裁剪,但画廊使用不同的类进行裁剪。所以裁剪仅适用于 android 2.1 中的画廊
  • 还有另一种解决方案,即先正常拍照,不使用裁剪,然后调用裁剪保存图像。更清楚地参考这个groups.google.com/group/android-developers/browse_thread/thread/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-16
  • 2013-05-26
  • 1970-01-01
  • 1970-01-01
  • 2016-03-26
  • 1970-01-01
相关资源
最近更新 更多