Reputation: 701
Hello I created a android code to take picture, the code worked well but when I get a copy of picture the resolutions is very low. How can I get full resolution. This is my code:
private void cameraIntent()
{
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra( MediaStore.EXTRA_OUTPUT, this.destinationUpload);
startActivityForResult(intent, REQUEST_CAMERA);
}
private void onCaptureImageResult(Intent data) {
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
thumbnail.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File destination = new File(Environment.getExternalStorageDirectory(),"img.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();
}
}
Upvotes: 0
Views: 424
Reputation: 4087
You're going to have so much fun supporting all the different camera applications.
You're half way there. The docs say that
The caller may pass an extra EXTRA_OUTPUT to control where this image will be written. If the EXTRA_OUTPUT
intent.putExtra( MediaStore.EXTRA_OUTPUT, this.destinationUpload);
tells the camera app to save the image to the file at destinationUpload
. Now you can read that file, or you can get a MediaStore URI to that file. The latter will work better for sharing.
Use
MediaScannerConnection.scanFile(context, new String[]{file.getAbsolutePath()}, null, new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
callback.result(uri);
}
});
Upvotes: 2