From 7aa1170ab4fee54e22ee045a956ccbdb4535bcbf Mon Sep 17 00:00:00 2001 From: l30052832 Date: Fri, 21 Jun 2024 14:28:46 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=84=A6=E8=B7=9D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/pages/Index.ets | 27 +++++++++++----------- entry/src/main/ets/utils/CameraShooter.ets | 9 +++++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 03024ae..8879774 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -82,8 +82,8 @@ struct XComponentPage { @LocalStorageLink('isMovingPhoto') isMovingPhoto: boolean = false; textTimerController: TextTimerController = new TextTimerController(); uri: string = ''; - @State rotation:number=0; - @State isShowZoom:boolean=false; + @State rotation: number = 0; + @State isShowZoom: boolean = false; onPageShow(): void { filePreview.closePreview(context); @@ -255,12 +255,12 @@ struct XComponentPage { PinchGesture({ fingers: 2 }) .onActionUpdate((event: GestureEvent) => { if (event && !this.isStabilization) { - this.zoom = this.zoom *(( event.scale-1) * 0.07+1) - this.isShowZoom=true - if(this.zoom>zoomRatioRange[1]){ - this.zoom=zoomRatioRange[1] - }else if(this.zoom zoomRatioRange[1]) { + this.zoom = zoomRatioRange[1] + } else if (this.zoom < zoomRatioRange[0]) { + this.zoom = zoomRatioRange[0] } if (this.isPhoto) { setPhotoZoom(this.zoom); @@ -270,7 +270,7 @@ struct XComponentPage { } }) .onActionEnd((event: GestureEvent) => { - this.isShowZoom=false + this.isShowZoom = false }) ) .onLoad(async () => { @@ -328,10 +328,11 @@ struct XComponentPage { } .visibility(this.isFront || this.isStabilization ? Visibility.Hidden : Visibility.Visible) .margin({ top: CameraConstants.PREVIEW_HEIGHT_BUTTON }) - Text(this.zoom.toFixed(0)+'x') + + Text(this.zoom === zoomRatioRange[0] ? '广角' : this.zoom.toFixed(1) + 'x') .fontColor(Color.White) .margin({ top: '1000px' }) - .visibility(this.isShowZoom?Visibility.Visible:Visibility.Hidden) + .visibility(this.isShowZoom && !this.isFront ? Visibility.Visible : Visibility.Hidden) } Row() { @@ -385,8 +386,8 @@ struct XComponentPage { .height(CameraConstants.CAMERA_SWITCH_SIZE) .width(CameraConstants.CAMERA_SWITCH_SIZE) .borderRadius(CameraConstants.CAMERA_SWITCH_SIZE / 2) - .rotate({angle:this.rotation}) - .animation({curve:curves.springMotion()}) + .rotate({ angle: this.rotation }) + .animation({ curve: curves.springMotion() }) .onClick(() => { if (this.currentPic) { previewPhoto(this.isMovingPhoto, context, this.uri); diff --git a/entry/src/main/ets/utils/CameraShooter.ets b/entry/src/main/ets/utils/CameraShooter.ets index 07189e2..c5c59a1 100644 --- a/entry/src/main/ets/utils/CameraShooter.ets +++ b/entry/src/main/ets/utils/CameraShooter.ets @@ -88,13 +88,20 @@ export async function cameraShooting(isVideo: boolean, cameraPosition: number, s width: 1920, height: 1080 } - ; let photoProfile: undefined | camera.Profile = photoProfilesArray.find((profile: camera.Profile) => { return profile.size.width === photoSize.width && profile.size.height === photoSize.height; }); let previewProfile: undefined | camera.Profile = previewProfilesArray.find((profile: camera.Profile) => { return profile.size.width === previewSize.width && profile.size.height === previewSize.height; }); + if (cameraPosition === 0 && foldAbleStatus != 0) { + photoProfile = photoProfilesArray.find((profile: camera.Profile) => { + return profile.size.width === 1920 && profile.size.height === 1080; + }); + previewProfile = previewProfilesArray.find((profile: camera.Profile) => { + return profile.size.width === 1920 && profile.size.height === 1080; + }); + } previewOutput = cameraManager.createPreviewOutput(previewProfile, surfaceId); if (previewOutput === undefined) { return []; -- Gitee