java - Image from android camera with right side up -
java - Image from android camera with right side up -
i'm trying show user image photographic camera right side - no regard how holds phone.
my code simple:
intent cameraintent = new intent(mediastore.action_image_capture); cameraintent.putextra("return-data", true); startactivityforresult(cameraintent, camera_result);
then attach returned image imageview in onactivityresult.
i know how rotate image, how can know how user hold photographic camera when took picture?
i'm sure can't using "return-data" extra. you'll have pass filename of wan't image created, , utilize exif of file check orientation.
string folder = "your_folder"; string filename = "your_filename"; int take_photo_request_code = 0; file photofile; void takephoto() { intent takepictureintent = new intent(mediastore.action_image_capture); photofile = new file(folder , filename ); uri picturefileuri = uri.fromfile(photofile); takepictureintent.putextra(android.provider.mediastore.extra_output, picturefileuri); startactivityforresult(takepictureintent, take_photo_request_code); } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); switch(requestcode) { case take_photo_request_code: if(resultcode == result_ok) { int orientation = 0; seek { exifinterface exif = new exifinterface(path); int exiforientation = exif.getattributeint(exifinterface.tag_orientation, -1); switch (exiforientation) { case exifinterface.orientation_normal: orientation = 0; break; case exifinterface.orientation_rotate_90: orientation = 90; break; case exifinterface.orientation_rotate_180: orientation = 180; break; case exifinterface.orientation_rotate_270: orientation = -90; break; } } grab (ioexception e) { // todo auto-generated grab block e.printstacktrace(); } } // here can rotate bitmap knowing orientation of photographic camera when photo taken } }
java android image camera
Comments
Post a Comment