简体   繁体   中英

Camera orientation and preview size

I just need some clarification with something regarding camera previews

In Android developer documentation they have this under the description for setPreviewSize() :

DIRECT LINK

suppose the camera supports both 480x320 and 320x480 preview sizes. The application wants a 3:2 preview ratio. If the display orientation is set to 0 or 180, preview size should be set to 480x320. If the display orientation is set to 90 or 270, preview size should be set to 320x480. The display orientation should also be considered while setting picture size and thumbnail size.

So in my code I am able to rotate the camera orientation to be straight, this works fine. So changing my orientation 90 degrees makes my camera straight.

Now I want a 4:3 image, one of my supported preview sizes is 1440x1080 , according to the block quote above this would mean I need to change my preview size to:

p.setPreviewSize(1080,1440);

But obviously this isnt a supported resolution for my device, so the app will crash.

here are my supported preview sizes, what do I do if I dont have a supported preview where I dont have the above scenario (block quote text)

iterator D/CAMERA: width: 1920 height 1080 -----
iterator D/CAMERA: width: 1440 height 1080 -----
iterator D/CAMERA: width: 1088 height 1088 -----
iterator D/CAMERA: width: 1280 height 720 -----
iterator D/CAMERA: width: 1056 height 704 -----
iterator D/CAMERA: width: 1024 height 768 -----
iterator D/CAMERA: width: 960 height 720 -----
iterator D/CAMERA: width: 800 height 450 -----
iterator D/CAMERA: width: 720 height 720 -----
iterator D/CAMERA: width: 720 height 480 -----
iterator D/CAMERA: width: 640 height 480 -----
iterator D/CAMERA: width: 352 height 288 -----
iterator D/CAMERA: width: 320 height 240 -----
iterator D/CAMERA: width: 256 height 144 -----
iterator D/CAMERA: width: 176 height 144 -----

I need my image to be 4:3

From what I researched, you can only use supported preview sizes: stackoverflow.com/a/8051114/6286328 and stackoverflow.com/a/6952604/6286328 . Perhaps your best shot is to get a similar suppored preview size (according to your required proportion) and test to see how it gets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM