gpt4 book ai didi

java - 无法实现图像裁剪

转载 作者:太空宇宙 更新时间:2023-11-04 09:24:19 24 4
gpt4 key购买 nike

当我同步 API 'com.theartofdev.edmodo:android-image-cropper:2.8.+' 时,它会强调实现 'com.android.support:appcompat-v7:28.0.0':

enter dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:gridlayout-v7:28.0.0'
api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'


}



最佳答案

您的用例是什么?你有什么格式的图像? (位图、Uri 或位于 blob 存储中)为什么不调整图像大小而不是裁剪?

如果图像位于位图中,这里是调整大小的代码(如果有帮助的话)

 /**
* reduces the size of the image
* @param image
* @param maxSize
* @return
*/
fun getResizedBitmap(image: Bitmap, maxSize: Int): Bitmap {
var width: Int = image.width
var height: Int = image.height

val bitmapRatio: Double = (width / height).toDouble()
if (bitmapRatio > 1) {
width = maxSize
height = (width / bitmapRatio).toInt()
} else {
height = maxSize
width = (height * bitmapRatio).toInt()
}
return Bitmap.createScaledBitmap(image, width, height, true)
}

关于java - 无法实现图像裁剪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57918679/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com