Bitmap in putExtra
2019. 12. 20. 15:36ㆍKotlin
반응형
// putExtra Activity
val bimap = BitmapFactory.decodeFile(path) // example
val stream = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream)
val byteArray = stream.toByteArray()
startActivityForResult(Intent(this, TestActivity::class.java).apply {
putExtra("bitmap", byteArray)
}, 100)
// TestActivity
private var mBitmap: Bitmap? = null
onCreate(){
intent.let {
it.getByteArrayExtra("bitmap")?.let { arr ->
mBitmap = BitmapFactory.decodeByteArray(arr, 0, arr.size)
}
}
}
반응형
'Kotlin' 카테고리의 다른 글
Bitmap to File (0) | 2019.12.20 |
---|---|
zip, unzip (0) | 2019.12.20 |
BitmapFromAsset (0) | 2019.12.20 |
Snackbar (0) | 2019.12.20 |
MVVM (0) | 2019.12.12 |