简体   繁体   English

显示相机预览未全屏显示

[英]Showing Camera Preview not taking full screen

I am using S3 With Camera.Size comes to be 720*1280 Same as the screen size. 我正在使用S3和Camera.Size变为720 * 1280与屏幕尺寸相同。

However, The camera surface appears only like the picture below not covering full screen (Length wise yes but not width wise) 但是,相机表面仅显示为下面的图片而不覆盖全屏(纵向是,但不横向)

在此处输入图片说明

I tried setting 我尝试设置

  @Override
  public void onSurfaceTextureAvailable(SurfaceTexture surface,
                                        int width, int height) {
    this.surface=surface;

    cameraView.previewCreated();
    cameraView.initPreview(width, height);
  }

as

cameraView.initPreview(720, 1280); cameraView.initPreview(720,1280);

But it had only negligible effect. 但是它的作用微不足道。

My question is, How can i make it expand to full screen like a Camera Application. 我的问题是,如何使它像“相机应用程序”一样扩展到全屏。 What is going on in here. 这是怎么回事。

Same results come up in Demo application. 在演示应用程序中得出相同的结果。 In my HTC results are better but still there are spaces. 在我的HTC中,效果更好,但仍有空间。

This is working as designed, though what you want will be in the 0.6.0 version. 尽管您想要的将是0.6.0版本,但这仍按设计工作。

Quoting an upcoming version of the project README : 引用项目README的即将发布的版本:


The default behavior of CameraFragment and CameraView is to show the entire preview, as supplied by the underlying Camera API. CameraFragmentCameraView的默认行为是显示由基础Camera API提供的整个预览。 Since the aspect ratio of the preview frames may be different than the aspect ratio of the CameraView , this results in a "letterbox" effect, where the background will show through on one axis on the sides. 由于预览帧的纵横比可能与CameraView的纵横比不同,因此会产生“信箱”效果,其中背景将在侧面的一个轴上显示。

If you want the preview to completely fill the CameraView , at the cost of cropping off some of the actual preview frame, have your CameraHost return true from useFullBleedPreview() . 如果您希望预览完全填满CameraView ,但要以裁剪一些实际的预览框为代价,请让CameraHostuseFullBleedPreview()返回true

Note that the pictures and videos taken by this library are unaffected by useFullBleedPreview() . 请注意,此库拍摄的图片和视频不受useFullBleedPreview() Hence, if useFullBleedPreview() returns true , the picture or video may contain additional content on the edges that was not visible in the preview. 因此,如果useFullBleedPreview()返回true ,则图片或视频可能在预览中不可见的边缘上包含其他内容。


Support for useFullBleedPreview() will be in version 0.6.0 of the library, though the source code for it is already pushed to the repo and is available in the master branch. useFullBleedPreview()支持将在库的0.6.0版中进行,尽管它的源代码已被推送到仓库中,并且在master分支中可用。 You are welcome to keep tabs on this issue for further developments. 欢迎您随时关注此问题,以进行进一步的开发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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