Skip to content

Commit a2e8d5c

Browse files
authored
Merge pull request #17 from bonepeople/main
Fix the problem that CropTransformation is not cropping
2 parents 2e0767a + b7e9082 commit a2e8d5c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

transformations/src/main/java/com/commit451/coiltransformations/CropTransformation.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.graphics.Canvas
55
import android.graphics.RectF
66
import androidx.core.graphics.createBitmap
77
import coil.size.Size
8+
import coil.size.pxOrElse
89
import coil.transform.Transformation
910
import com.commit451.coiltransformations.Util.safeConfig
1011
import kotlin.math.max
@@ -26,8 +27,8 @@ class CropTransformation(
2627
override val cacheKey: String = "${CropTransformation::class.java.name}-$cropType"
2728

2829
override suspend fun transform(input: Bitmap, size: Size): Bitmap {
29-
val width = input.width
30-
val height = input.height
30+
val width = size.width.pxOrElse { input.width }
31+
val height = size.height.pxOrElse { input.height }
3132

3233
val output = createBitmap(width, height, input.safeConfig)
3334

0 commit comments

Comments
 (0)