android - Captured image is rotated 90 degress -


i've written app capture image. problem image rotated 90 degrees after capture. i've setted the

camera.setdisplayorientation(ninty_degrees); 

but affects previewing of surfaceview. real problem bytes camera flipped. why happend? there setting can set flip before capture?

i activity subcribes event, when image captured. how register when byte[] filled:

camera.takepicture(null, null, new picturecallback() {             @override             public void onpicturetaken(byte[] data, camera camera) {                 if (null != callback)                     callback.onjpegpicturetaken(data, camera);             }         }); 

in activity

public class history extends basewindow implements onclicklistener, captureimagecallback 

and relevant method:

@override public void onjpegpicturetaken(byte[] data, camera camera) {         intent = new intent(this, imageediting.class);         i.putextra("image", data);         startactivity(i); } 

you can see parameter data contains image data, byte array rotated 90 degress. of course rotate imageview 90 degress, since work other systems, such homemade webservice, need apply hot fix every external system. how can correct rotation?

thanks!

you can "angle" of captured image , rotate per angle.

exifinterface exif = new exifinterface(imagepath); int orientation = exif.getattributeint(exifinterface.tag_orientation,exifinterface.orientation_normal);  int angle = 0;  if (orientation == exifinterface.orientation_rotate_90) {     angle = 90; } else if (orientation == exifinterface.orientation_rotate_180) {     angle = 180; } else if (orientation == exifinterface.orientation_rotate_270) {     angle = 270; }  log.d("tag", "angle: " + angle);  matrix mat = new matrix(); mat.postrotate(angle);  if (angle != 0)     bitmap bitmap2 = bitmap.createbitmap(bitmap, 0, 0, bitmap.getwidth(),bitmap.getheight(), mat, true); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -