HarmonyOS 自定义相机拍照后的图片位置略有偏移

自定义相机拍照后,获取的图片显示不是镜像的,并且位置略有偏移。

然后设置了镜像:

let photoCaptureSetting: camera.PhotoCaptureSetting = {
  quality: camera.QualityLevel.QUALITY_LEVEL_HIGH, // 设置图片质量高
  rotation: camera.ImageRotation.ROTATION_0, // 设置图片旋转角度0
  mirror: this.cameraManager.photoOutput?.isMirrorSupported() ? true : false // 镜像
}
await this.cameraManager.photoOutput?.capture(photoCaptureSetting).catch((error: BusinessError) => {
  console.log('拍照失败', JSON.stringify(error));
  return
});
// 拍照成功
this.cameraManager.setHasPicture(true)
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

最后获取的照片是想要的镜像效果,但是位置也是略有偏移的,跟相机里面的照片位置不一致。

HarmonyOS
2024-12-25 15:45:18
1.8w浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
zxjiu

setXComponentSurfaceRect做如下设置。

let displaydef = display.getDefaultDisplaySync()
this.mXComponentController.setXComponentSurfaceRect({offsetX:0,offsetY:0, surfaceWidth: displaydef.height * 1080.0/1920.0, surfaceHeight: displaydef.height});
  • 1.
  • 2.

然后图片保存逻辑打开后,拍摄出来的照片和预览的尺寸是一样的,没有偏移。

但是拍完后展示的image组件,设置全屏,全屏的宽高比是和照片的宽高比不同,所以显示出来的感觉是偏移的。

建议优化拍完后image显示的ui设计。

分享
微博
QQ
微信
回复
2024-12-25 17:41:21


相关问题
HarmonyOS 自定义相机拍照数据展示
1390浏览 • 1回复 待解决
HarmonyOS 自定义相机拍照不成功
735浏览 • 1回复 待解决
HarmonyOS 自定义拍照功能
476浏览 • 1回复 待解决
HarmonyOS 自定义相机demo
1103浏览 • 1回复 待解决
HarmonyOS 如何自定义相机
572浏览 • 1回复 待解决
HarmonyOS 自定义相机功能
649浏览 • 1回复 待解决
HarmonyOS 自定义相机预览问题
637浏览 • 1回复 待解决
HarmonyOS 拍照自定义取景范围
228浏览 • 1回复 待解决
HarmonyOS 自定义相机演示demo
745浏览 • 1回复 待解决
HarmonyOS 关于自定义相机功能
704浏览 • 1回复 待解决
HarmonyOS 如何自定义相机背景
539浏览 • 1回复 待解决
如何设置自定义弹窗位置
2474浏览 • 1回复 待解决
HarmonyOS 自定义相机预览拉伸问题
509浏览 • 1回复 待解决
HarmonyOS 使用自定义相机左边有间距
522浏览 • 1回复 待解决