文档管理中心
FAQ媒体开发拍照和图片相机开发(Camera)视频预览分辨率设置

视频预览分辨率设置

问题现象

旋转手机,预览画面中物品高度变化明显,画面畸变。代码中的预览分辨率:previewProfile {"format":1003,"size":{"width":3200,"height":2400}},XComponent的surfaceWidth: 3200, surfaceHeight: 2400。

收起
自动换行
深色代码主题
复制
  1. XComponent({
  2. id: 'componentId',
  3. type: 'surface',
  4. controller: this.mXComponentController,
  5. }).onLoad(async () => {
  6. this.surfaceId = this.mXComponentController.getXComponentSurfaceId();
  7. let baseContext = this.getUIContext().getHostContext()! as common.BaseContext;
  8. await this.initCamera(baseContext, this.surfaceId)
  9. }).width('100%')
  10. .height('100%')

可能原因

XComponent宽高比设置不当。

解决措施

请确保.width('100%').height('100%')的值不都设置为100%,并保持width和height的比例与previewProfile的height与width比例一致。

在 FAQ 中进行搜索
请输入您想要搜索的关键词