简体   繁体   中英

What is the relationship between screenSize, previewSize and pictureSize in Android camera?

I think many people feel confused like me between these few sizes.
Let me declare something: ratio = width/height.

In the surfaceView, we set previewSize and pictureSize as parameters.
But how to choose the best sizes??
If I want to capture a fullscreen image, what should the previewSize and pictureSize set to be?
There is some case that the preview is fullscreen but the saved image is bigger than the preview screen image, why?
Also, if the ratio of previewSize and pictureSize is different, is there any problems?
And, is it necessary to set the ratio of previewSize and screenSize the same?
To be honest, I just want to capture the fullscreen image and save it as jpg/png and the image saved is the exactly same width and height as preview, how to do it?
I just confused with the relationship between screenSize, previewSize and pictureSize. Thank.

So let's start with the definitions, as I understand them.

ScreenSize : The physical dimensions of the physical display, this is the maximum size of pixels available to the device to display content to a user. This is pretty much a static value.

PreviewSize : This is usually the size of the image that an optical sensor can natively preview frames at a fast rate. The sensor usually provides a list of supported values. These are usually all the same aspect ratio. A supported previewSize may overlap with the ScreenSize . If so and you want to display a full size camera view, great! Whatever one that is, is the one you want. Otherwise it's probably just the closest value, up to you after that.

PictureSize : This is the size of the actual capture from the sensor. This is has nothing to do with either the other two values actually. It will usually overlap with some of the previewSize supported values for sure. But it can range much larger and have a much better resolution supported in general, as this is the final product after all. Many times the capture may look better on a device capable of displaying a better resolution than the ScreenSize Aspects of these can be different.

ScreenSize and PreviewSize are usually the most related to the presentation of the image while it is scanning for potential images. These are usually really unfocused quick renders of whatever the sensor is able to see at the moment and display them ot the user (almost like a video feed in a sense). In those cases you want to give the best possible, but sometimes the camera might not be setup to take full advantage of a display. Ie a front facing camera is usually mounted in such a way that it is setup for capturing portrait type images and previews might not take advantage of the aspect ratio of the screen. This is purely cosmetic if you are not doing anything with the preview frames other than displaying them right to the screen. Otherwise it's more app specific at that point if this is a problem or not. Like for instance a front facing camera might have a 4:3 previewSize and the ScreenSize has a 16:9 ratio. You end up with the letterboxing or stretching solution which may be just right for what you are doing.

CaptureSize is usually not related to PreviewSize at all, as far as the developer is concerned. It's mildly related to ScreenSize only in cases where the captured file will only ever be displayed on the given device and never manipulated. Ie if you only take images for this one app and only display them on this one app. IF the capture size is HUGE, and the screen is small, it's a little bit of a waste of space. On the other hand, if the capture is smaller than the screensize and the sole purpose is to just display the images on the screen, if the capture is smaller than the screen, you may have to scale up. It is usually more related to a tradeoff of memory, filesize, and quality of capture for manipulation later in some other activity or process.

Pretty much it comes down to this. High res is great if you have the bandwidth, storage and memory to do everything. If not you can always scale. If scaling, I prefer to scale down usually only because it often results in a better displayed image, as opposed to scaling up.

The more I am thinking about this, it's sort of a vague question overall. Hopefully this gives some benefit.

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