android - My bitmap image is cropped -


i'm using 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 uri mi camera , send webserver via httpurlconnection object in post headers. instead original image: enter image description here

i cropped imagen:

enter image description here

i don't know why. perhaps decodeuri method wrong? know other best method send image compressed webserver?

i used right next way insteaf of decodeuri method:

mybitmap = mediastore.images.media.getbitmap(this.getcontentresolver(), selectedimageuri); 

and have same problem. , when tried open image in webserver photoshop, see advertisement wich says "this document may damaged (the file may truncated or incomplete). want continue?" , , after continue, see black space in bottom of image...

anybody knows why? 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 send in post headers:

 base64.encodetostring(baos.tobytearray(), base64.default); 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -