The following code is to save the image to a certain folder, which is taken by my application, but the image is saved with a horrible quality even if it is at most "100".
if (requestCode == 5) {
if (resultCode == RESULT_OK) {
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
try {
EditText nome = (EditText) findViewById(R.id.editTextScan);
String nome2 = String.valueOf(nome.getText());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] bytes = stream.toByteArray();
File arq = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "/Pasta/Qualidade/" + nome2+".png");
FileOutputStream fos = new FileOutputStream(arq);
fos.write(bytes);
fos.close();
Toast.makeText(getApplicationContext(), "Salvou foto", Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
}
} else if (resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Foto cancelada.", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "Cancelamento automático.", Toast.LENGTH_SHORT).show();
}
}