I have the following problem, in my application I take a photo and present it in a imageView
, but when I take the photo it gets the good quality in the gallery only in imageView
no, if it is a text not even to read, lower I'll put the camera code
private void cameraIntent() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUEST_CAMERA);
}
private void onCaptureImageResult(Intent data) {
bitmap = (Bitmap) data.getExtras().get("data");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, bytes);
File destination = new File(Environment.getExternalStorageDirectory(), System.currentTimeMillis() + ".jpg");
FileOutputStream fo;
try {
destination.createNewFile();
fo = new FileOutputStream(destination);
fo.write(bytes.toByteArray());
fo.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
imageView.setImageBitmap(bitmap);
fab.setVisibility(View.VISIBLE);
}
I imagine changing the way you look for the photo will solve the problem.
In this same application you also have the option to select an image from the gallery and in this option the image comes perfect without any change in quality.
private void galleryIntent() {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select File"),SELECT_FILE);
}
@SuppressWarnings("deprecation")
private void onSelectFromGalleryResult(Intent data) {
if (data == null)
return;
imagemUrl = data.getDataString();
if (imagemUrl != null) {
Glide
.with(this)
.load(imagemUrl)
.into(imageView);
}
fab.setVisibility(View.VISIBLE);
}