如何创建像谷歌照片应用程序图像裁剪工具的图像裁剪工具?我到处搜索,但没有发现任何像谷歌照片裁剪应用程序的库或代码。
我的意思是,这个应用程序的这个功能。我找到了很多库,但问题是,当我为图像旋转添加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" />
答案 0 :(得分:0)
您可以使用此方法裁剪图像。希望它会对你有所帮助。
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");
}
}
答案 1 :(得分:0)
我找到了这个很棒的图书馆,感谢创作者:* https://android-arsenal.com/details/1/3054
但是这个库与Google照片裁剪工具不完全相同