谷歌照片图像裁剪工具
问题描述:
如何创建像谷歌照片应用程序图像裁剪工具的图像裁剪工具?我到处搜索,但没有找到任何类似谷歌照片裁剪应用程序的库或代码。谷歌照片图像裁剪工具
我的意思是,这个应用程序的这个功能。我发现了很多库,但问题是,当我添加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" />
答
您可以使用此方法裁剪你的图像。希望它能帮助你。
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时,裁剪框架也在旋转 –