This is the code I´m using for an app and it is working fine:
public void onImageClick(View view){
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent
data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 1)
if (resultCode == Activity.RESULT_OK) {
Uri selectedImage = data.getData();
img.setImageURI(selectedImage);
}
on the layout:
<ImageView android:id ="@+id/pictureViewer2"
android:contentDescription="@string/imagen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:onClick="onImageClick"
android:adjustViewBounds="true"
android:scaleType ="fitCenter"
/>
To avoid cropping the important thing is the scaleType and
adjustViewBounds tags.
Hope this helps.
On 31 dic 2011, 20:12, "mr.winky" <[email protected]> wrote:
> I am writing an intent to allow the user to pull an image from the
> gallery:
>
> Intent getImage = new Intent(Intent.ACTION_GET_CONTENT);
>
> getImage.setType("image/*");
> getImage.putExtra("outputX", width);
> getImage.putExtra("outputY", height);
> getImage.putExtra("aspectX", width);
> getImage.putExtra("aspectY", height);
> getImage.putExtra("noFaceDetection", true);
> getImage.putExtra("scale", true);
> getImage.putExtra("crop", "true");
> getImage.putExtra("setWallpaper", false);
>
> startActivityForResult(Intent.createChooser(getImage, "Select
> Background Image"), 0x10);
>
> Everything is working fine and a new image is generated from the
> gallery except it looks like the image that comes back cropped is in a
> lower quality format from the original image, like 16 bit color format
> instead of 32 bit.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en