简体   繁体   中英

Android Emulator Camera Preview Sizes

At runtime I use getSupportedPreviewSizes() and it returns a single size (320x240). When I initialize a new camera however, it sets the Preview size to the size of the display (320x480) which isn't listed under the returned supported sizes. Why is this? Are you just simply able to override the supported preview sizes, and that's what's done by default? Or is this emulator related? (I would think it's an emulator thing).

If you mean by PreviewSize the size of the SurfaceView, you can change this by code after you get your camera resolution as follows:

FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(cameraRes.x, cameraRes.y);
surfaceView.setLayoutParams(params); 

If you mean the Camera preview size, you can set it as follows:

Camera.Parameters parameters = camera.getParameters();
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
camera.setParameters(parameters);

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