Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

android - Image rotation error in front and rear device camera photo capture intent

HI i have used the following device camera intent to capture and save the image in device storage:

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE,lastChar);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        // Start the image capture Intent
        startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);  

Everthing is just working fine , camera capturing the image ,saving it into the storage properly, but when i am trying to view the image by fetching image uri from storage and displaying it in the imageview. Image angle changing all the time. for Rear camera captured image rotation angle is 90 degree and for front camera capture image rotation angle is 270 degree.

i have added 90 degree rotation to all images , that resolving the rear camra problem , but front camera captured image still have the 180 degree rotation .

thanks in advance , please help me sorting out this issue

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Some cameras will actually store JPEG images in the proper rotation; others will set an EXIF header asking the image viewer to rotate the image. ImageView does not honor EXIF headers in JPEG files. You will need to use ExifInterface (or similar techniques) to see if there is an EXIF orientation header and adjust your image to suit.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...