now this is my code to take a photo from my smartphone, the problem is that the image is very large and I would like to compress it, some help or idea?
thanks for the info
Execution of the method abrirCamara()
private fun abrirCamara() {
val values = ContentValues()
values.put(MediaStore.Images.Media.TITLE, "Nueva foto")
values.put(MediaStore.Images.Media.DESCRIPTION, "Desde la camara")
image_uri = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values)
//intención de la cámara
val cameraIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, image_uri)
startActivityForResult(cameraIntent, IMAGE_CAPTURE_CODE)
}
is called when the user press PERMIT or DENY from the permission request pop-up window
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
when(requestCode){
PERMISSION_CODE -> {
if (grantResults.size > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED){
//permiso de popup fue concedido
abrirCamara()
}
else{
//el permiso de popup fue denegado
Toast.makeText(this, "Permiso denegado", Toast.LENGTH_SHORT).show()
}
}
}
}
Call when the image was captured from the camera's intention
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
//Llamada cuando la imagen fue capturada desde la intención de la cámara
if (resultCode == Activity.RESULT_OK){
//configurar imagen capturada a vista de imagen (ImageView)
imgEnvio.setImageURI(image_uri)
captura_btn.visibility =View.INVISIBLE
siguiente.visibility=View.VISIBLE
}
}