kotlin : bitmap 크기 조절하기
2023. 8. 25. 00:55ㆍ[Android APP] feat. Kotlin/Kotlin 공부
fun getResizedBitmap(bm: Bitmap, newHeight: Int, newWidth: Int): Bitmap {
val width = bm.width
val height = bm.height
val scaleWidth = newWidth.toFloat() / width
val scaleHeight = newHeight.toFloat() / height
val matrix = Matrix()
matrix.postScale(scaleWidth, scaleHeight)
return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false)
}
handler.postDelayed({
imageView.setImageBitmap(getResizedBitmap(bitmap, 1000, 1000))
}, 0)
반응형
'[Android APP] feat. Kotlin > Kotlin 공부' 카테고리의 다른 글
Kotlin : 사진 등록 처리 (0) | 2023.08.25 |
---|---|
Kotlin : RecyclerView snapHelper (0) | 2023.03.27 |
Kotlin : RecyclerView item EditText 중복 에러 해결 (0) | 2023.03.27 |
Kotlin : 명시적 인텐트(Explicit Intent), 암시적 인텐트(Implicit Intent) (0) | 2023.02.27 |
Kotlin : Lottie Library(애니메이션 적용) (0) | 2023.02.22 |