After two days of programming the Android Camera module, set various parameters, when the preview is found, the picture is reversed, not upside down but upside down 90°. My phone is Huawei U9200, with the Android4.0.3, later saw http://www.cnblogs.com/skyseraph/archive/2012/03/26/2418665.html this article, Add code: Mycamera.setdisplayorientation (90); Then the preview is normal. But the photos were opened on the computer and still tilted. Tilted 90°, later added this sentence: Myparameters.set ("Rotation", 90); This is to let the photo rotate 90° everything is OK! Previously set a lot of//myparameters.set ("Orientation", "Portrait");//setrequestedorientation (Activityinfo.screen_orientation_ PORTRAIT); Discovery has no effect. Just the two words above!
How do I see the previewsize and picturesize supported by my webcam? Here simply, Previewsize is the size of the preview, that is, the picture before the photo size, you can try, this parameter is set differently, in the same focal length, you take a fixed distance on the table of a thing, see the view will be different. Picturesize refers to the size of the final image, which is the quality of the picture. How to view it?
First at the beginning of the main program private static final String TAG = "Myandroid";
Then: List picturesizes;
List 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 check it out!
The parameters of my picturesize are:
The parameters of the preview are:
But I want to get a picture that ends up with a width of 600 and a height of 800. How about half? Here to illustrate the following, due to the preceding myparameters.set ("rotation", 90); If you set the camera picturesize parameter is m*n, the resulting picture size is n*m because you rotated it. How can I get a picture of the size I want,
FileOutputStream fout = new FileOutputStream (ftest);
Bufferedoutputstream BOS = new Bufferedoutputstream (fout);
Bitmap Mbitmap = Bitmap.createscaledbitmap (BM, n, +, true);
Mbitmap.compress (Bitmap.CompressFormat.JPEG, N, BOS);
Bm.compress (Bitmap.CompressFormat.JPEG, N, BOS);
Add the red part of the code to it. BM is the original photo data and is a bitmap. If you want to get the original size, remove the red and add the last sentence.
Android Camera module programming photo inversion problem and query camera parameter problem solving