Android custom camera image inverted Solution

Source: Internet
Author: User

Some mobile phone images are upside down. How can this problem be solved? See the following public static void setCameraDisplayOrientation (Activity activity, int cameraId, android. hardware. camera camera) {android. hardware. camera. cameraInfo info = new android. hardware. camera. cameraInfo (); android. hardware. camera. getCameraInfo (cameraId, info); int rotation = activity. getWindowManager (). getdefadisplay display (). 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;} int result; if (info. facing = Camera. cameraInfo. CAMERA_FACING_FRONT) {result = (info. orientation + degrees) % 360; result = (360-result) % 360; // compensate the mirror} else {// back-facing result = (info. orientation-degrees + 360) % 360;} camera. setDisplayOrientation (result );}


@Overridepublic void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {// TODO Auto-generated method stub
                setCameraDisplayOrientation(this,0,camera)
}



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.