I'm using this method:
public Bitmap decodeUri(Uri selectedImage) throws FileNotFoundException {
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeStream(getContentResolver().openInputStream(selectedImage), null, o);
final int REQUIRED_SIZE = 800;
int width_tmp = o.outWidth, height_tmp = o.outHeight;
int scale = 1;
while (true) {
if (width_tmp / 2 < REQUIRED_SIZE || height_tmp / 2 < REQUIRED_SIZE) {
break;
}
width_tmp /= 2;
height_tmp /= 2;
scale *= 2;
}
BitmapFactory.Options o2 = new BitmapFactory.Options();
o2.inSampleSize = scale;
return BitmapFactory.decodeStream(getContentResolver().openInputStream(selectedImage), null, o2);
}
To decode an URI from mi camera and then send to my webserver via an HttpURLConnection object in POST headers. But my instead get my original image:

I get a cropped image:
I don't know why. Perhaps my decodeURI method is wrong? Anybody know other best method to send my image compressed to my webserver?
I used right now the next way instead of my decodeUri method:
mybitMap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImageUri);
and I have the same problem. And when I tried to open the image in my webserver with Photoshop, I see an advertisement which says "This document may be damaged (the file may be truncated or incomplete). Do you want continue?" And , after continue, I see a black space in the bottom of the image...
Anybody knows why? My code:
Bitmap mybitMap = null;
try {
mybitMap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), selectedImageUri);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imagen.compress(Bitmap.CompressFormat.JPEG, 100, baos);
And I send this in POST Headers:
Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT);
