【问题标题】:How can I edit a photo taken via the camera in my application?如何在我的应用程序中编辑通过相机拍摄的照片?
【发布时间】:2013-02-28 18:20:07
【问题描述】:

在我的应用程序中,我使用相机拍照。
我使用此代码启动相机 Activity:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
timeStamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
File file = new File(directory, timeStamp+".png"); //name 
Uri outputFileUri1 = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri1);
startActivityForResult(intent, CAMERA_RESULT);

此代码正在运行,但如何在我的主 Activity 获取 onActivityResult() 中的数据之前编辑预览图像(裁剪、旋转...)?
或者如何从我的应用程序中为我的图片启动照片编辑器?

【问题讨论】:

    标签: android editor photo


    【解决方案1】:

    您应该从您的图像中创建一个Bitmap 对象,然后您可以对其进行操作。

    String fooFile = "PATH TO FILE";
    Bitmap bmp = BitmapFactory.decodeFile(fooFile);
    

    这是一个作物example。有关更多示例,请参见 Google 的“位图操作 android”

    【讨论】:

    • 哦,不......这是我的应用程序的一部分的示例算法:1)用户启动相机活动; 2)用户按下按钮拍摄照片; 3)用户确认照片(点击“检查”) 4)程序在onActivityResult中获取数据,其中创建Bitmap对象并在ImageView中加载图片。但我希望在“2)”和“3)”点之间,用户可以编辑照片(例如,裁剪照片),并在确认主要活动后得到裁剪照片。
    • 我需要实现你自己的相机活动,它将连接到相机并根据用户交互处理数据
    猜你喜欢
    • 2012-03-31
    • 1970-01-01
    • 2018-09-10
    • 2023-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    相关资源
    最近更新 更多