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.