I have problem with intent
in android
. I use intent
transfer image have been made by camera (camera of device) to bitmap
, and then I show it. But it's too small. My camera is 8mpx.
so why and how can I fix it?
Asked
Active
Viewed 275 times
0
-
2pass a path, not a binary image – pskink Jul 17 '15 at 06:59
-
possible duplicate of [Android camera intent](http://stackoverflow.com/questions/2729267/android-camera-intent) – Vladyslav Matviienko Jul 17 '15 at 07:09
-
You must use file system to store raw data. Save your bitmap and pass path. – Aleksandr Jul 17 '15 at 07:37
-
that mean, i need save image in device before i show? – PhuongFuk Jul 17 '15 at 08:27
2 Answers
0
Could you be more specific, Is the photo taken directly from camera or selected from gallery? Most probably the size of the imageView itself is small. A photo no matter how small can be enlarged to fit a large imageView but it will pixelate.
If you have its URI you could try this code to convert data from intent to uri which then gets converted to bitmap and then assigned to your imageView
Uri imageUri = intent.getData();
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(),imageUri);
Imageview imgview1 = (Imageview ) findViewById (R.id.imgview1);
imgeview1.setImageBitmap(bitmap);
You could use the above code to convert URI recieved from camera to a bitmap and assign it to the imageView. If the image still looks small then check the size of the imageView.

Domain
- 11,562
- 3
- 23
- 44
-
sorry but i don't know how to use your code :D I had save my image to sdcard with other code. You can tell me more detail :) – PhuongFuk Jul 17 '15 at 09:13
-
You could use the code here to access the image which you have currently stored kindly look into it http://stackoverflow.com/questions/25821239/how-to-set-selected-image-from-sd-card-on-imageview-in-android – Domain Jul 17 '15 at 09:24
0
private static final int TAKE_PICTURE = 1;
private Uri imageUri;
public void takePhoto(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photo));
imageUri = Uri.fromFile(photo);
startActivityForResult(intent, TAKE_PICTURE);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case TAKE_PICTURE:
if (resultCode == Activity.RESULT_OK) {
Uri selectedImage = imageUri;
getContentResolver().notifyChange(selectedImage, null);
ImageView imageView = (ImageView) findViewById(R.id.ImageView);
ContentResolver cr = getContentResolver();
Bitmap bitmap;
try {
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
imageView.setImageBitmap(bitmap);
Toast.makeText(this, selectedImage.toString(),
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT)
.show();
Log.e("Camera", e.toString());
}
}
}
}
Please follow the instruction of below link http://developer.android.com/guide/topics/media/camera.html

USKMobility
- 5,721
- 2
- 27
- 34