Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class ETImage(
rgbValues[(y * width + x) + 2 * height * width] = blue.toByte()
}
}
bitmap.recycle()
return rgbValues
} catch (e: FileNotFoundException) {
throw RuntimeException(e)
Expand All @@ -87,15 +88,21 @@ class ETImage(
private fun resizeImage(uri: Uri, sideSize: Int): Bitmap? {
val inputStream = contentResolver.openInputStream(uri)
if (inputStream == null) {
ETLogging.getInstance().log("Unable to resize image, input streams is null")
ETLogging.getInstance().log("Unable to resize image, input stream is null")
return null
}
val bitmap = BitmapFactory.decodeStream(inputStream)
val bitmap = inputStream.use {
BitmapFactory.decodeStream(it)
}
if (bitmap == null) {
ETLogging.getInstance().log("Unable to resize image, bitmap during decode stream is null")
return null
}

return Bitmap.createScaledBitmap(bitmap, sideSize, sideSize, false)
val scaled = Bitmap.createScaledBitmap(bitmap, sideSize, sideSize, true) // ← bilinear
if (scaled !== bitmap) {
bitmap.recycle()
}
return scaled
}

}