java - will Camera.Parameters:: setRotation rotate the image taken by samsung s2 camera? -
galaxy s2 takes portrait photos , add them oritentation_rotation_90 exif tag
.
thus when upload photo server presented in landscape.
i'm using min api 8.
i'm confused, , i'll appreciate if explain.
1) have tried:
exifinterface exif; try { exif = new exifinterface(imagefilename); int orientation = exif.getattributeint(exifinterface.tag_orientation, exifinterface.orientation_normal); exif.setattribute(exifinterface.tag_orientation, string.valueof(exifinterface.orientation_rotate_270)); //also tried exifinterface.orientation_rotate_undefined) exif.saveattributes(); orientation = exif.getattributeint(exifinterface.tag_orientation, exifinterface.orientation_normal); boolean b = orientation == configuration.orientation_landscape; } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); }
but didn't help. attributes changed, image still in landscape.
2) current solution:
create new rotated bitmap in client side.
but might costly.
3) suggested solution:
camera.parameters:: setrotation
... camera driver may rotate picture , exif thumbnail. if jpeg picture rotated, orientation in exif header missing or 1 (row #0 top , column #0 left side).
and saw code:
public void onorientationchanged(int orientation) { if (orientation == orientation_unknown) return; int rotation = activity.getwindowmanager().getdefaultdisplay() .getrotation(); int degrees = 0; switch (rotation) { case surface.rotation_0: degrees = 0; break; case surface.rotation_90: degrees = 90; break; case surface.rotation_180: degrees = 180; break; case surface.rotation_270: degrees = 270; break; } parameters.setrotation(degrees ); mcamera.setparameters(parameters); }
will (3) work needs?
another friend in stackoverflow said (2) work me
but couldn't understand why.
Comments
Post a Comment