当我同步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或在blop存储区中)
为什么不调整图像大小而不是裁切呢?
如果图像在位图中,这是用于调整大小的代码(如果有帮助)
/**
* 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)
}