【问题标题】:Google Photos image cropping tool谷歌相册图片裁剪工具
【发布时间】:2019-05-22 19:32:18
【问题描述】:

如何创建像谷歌照片应用图像裁剪工具这样的图像裁剪工具?我到处搜索,但没有找到任何类似于谷歌照片裁剪应用程序的库或代码。

我的意思是,这个应用程序的这个功能。我找到了很多库,但问题是,当我为图像旋转添加 seekBar 时,它正在旋转孔视图(图像和裁剪框),我想要,裁剪框不旋转。

我试过这个库https://android-arsenal.com/tag/45

这是我的旋转代码,这是库https://github.com/jdamcd/android-crop

private void rotateClick(){
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            imageView.setRotation(progress)
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
}

和xml

 <SeekBar
    android:id="@+id/seekBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<com.soundcloud.android.crop.CropImageView
    android:layout_marginTop="20dp"
    android:id="@+id/crop_image"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scaleType="center"
    android:adjustViewBounds="true"
    android:layout_below="@id/done_cancel_bar" />

【问题讨论】:

    标签: android image-processing


    【解决方案1】:

    您可以使用此方法裁剪图像。希望对你有所帮助。

     public static void copyFile(File src, File dst) {
        try {
            dst.createNewFile();
            FileInputStream inStream = new FileInputStream(src);
            FileOutputStream outStream = new FileOutputStream(dst);
            FileChannel inChannel = inStream.getChannel();
            FileChannel outChannel = outStream.getChannel();
            inChannel.transferTo(0, inChannel.size(), outChannel);
            inStream.close();
            outStream.close();
        }catch (IOException e) {
            Log.e("copy", "failed copy");
        }
    }
    

    【讨论】:

    • 我有裁剪功能。我唯一的问题是,当我旋转 imageView 时,裁剪框也在旋转
    【解决方案2】:

    我找到了这个很棒的库,感谢创建者:* https://android-arsenal.com/details/1/3054

    但这个库与谷歌照片裁剪工具并不完全相同

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-21
      • 2012-08-25
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      • 2015-05-08
      • 2012-04-27
      相关资源
      最近更新 更多