Android camera module programming photo reversing and querying camera parameters

Source: Internet
Author: User

In the past two days, after programming the android camera module and setting various parameters, we found that during previewing, the photos were reversed, rather than up or down, but 90 °. My mobile phone is u9200 and I used android4.0.3. Later I saw fuse (90), and then the preview was normal. However, the photos are still skewed when they are opened on the computer. Tilted 90 °, and then added this sentence: myparameters. Set ("rotation ",
90); this is to make the photo Rotate 90 ° everything is normal! Many parameters have been set before // myparameters. Set ("orientation", "portrait"); or // setrequestedorientation (activityinfo. screen_orientation_portrait. The above two sentences are missing!

How can I view the previewsize and picturesize supported by my camera? To put it simply, previewsize is the preview size, that is, the image size before taking the picture. You can try it. this parameter is set differently under the same focal length, you can take a picture of something at a fixed distance on the table and see different visual views. Picturesize refers to the size of the final image, that is, the image quality. How can I view it?

First, at the beginning of the main program, Private Static final string tag = "myandroid ";

Then: List <size> picturesizes;
List <size> previewsizes;

For (INT I = 0; I <picturesizes. Size (); I ++)
{
Psize = picturesizes. Get (I );
Log. I (TAG + "initcamera", "pictruesize, width:" + psize. Width + "height" + psize. Height );
}
For (INT I = 0; I <previewsizes. Size (); I ++)
{
Psize = previewsizes. Get (I );
Log. I (TAG + "initcamera", "previewsize, width:" + psize. Width + "height" + psize. Height );
}

You can view it!

The parameters of my picturesize are:


The preview parameters are:


But I want to get an image with the final width of 600 and the height of 800. Why? The preceding myparameters. set ("rotation", 90); if you set the camera picturesize parameter to M * n, the image size is N * m, because you have rotated. How can I get the image of the specified size,

Fileoutputstream fout = new fileoutputstream (ftest );
Bufferedoutputstream Bos = new bufferedoutputstream (fout );
Bitmap mbitmap = bitmap. createscaledbitmap (BM, 600,800, true );
Mbitmap. Compress (bitmap. compressformat. JPEG, 100, Bos );

//
BM. Compress (bitmap. compressformat. JPEG, 100, Bos );

Add the red part of the code. BM is the initial photo data and a bitmap. If you want to get the original size, remove the red color and add the last sentence.

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.