diff --git a/lib/features/analysis/analysis_screen.dart b/lib/features/analysis/analysis_screen.dart index 70f4b6fd..7b87824b 100644 --- a/lib/features/analysis/analysis_screen.dart +++ b/lib/features/analysis/analysis_screen.dart @@ -287,7 +287,7 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> { radius, ringCount: ringCount, ringRadii: ringRadii, - zoomScale: widget.cropScale ?? 1.0, + zoomScale: 1.0, ); }, ), diff --git a/lib/features/crop/crop_screen.dart b/lib/features/crop/crop_screen.dart index b350896c..fd100034 100644 --- a/lib/features/crop/crop_screen.dart +++ b/lib/features/crop/crop_screen.dart @@ -361,7 +361,7 @@ class _CropScreenState extends State { final minDisplayDim = math.min(displayWidth, displayHeight); // 2. Calcul du scale initial basé sur la dimension de l'image (et non du viewport) - _scale = widget.initialScale ?? (_cropSize / minDisplayDim); + _scale = widget.initialScale ?? 1.0; if (_scale < 1.0 && widget.initialScale == null) _scale = 1.0; // 3. Réinitialisation propre de l'offset au centre de la zone d'affichage @@ -389,17 +389,26 @@ class _CropScreenState extends State { Future _onCropConfirm() async { setState(() => _isLoading = true); try { + // CORRECTIF ZOOM : On sauvegarde et réinitialise le zoom avant de calculer + // la zone de découpe pour ne pas transmettre le zoom aux écrans suivants + final savedScale = _scale; + final savedOffset = _offset; + _scale = 1.0; + _offset = Offset.zero; + final cropRect = _calculateCropRect(); + // On restaure pour l'affichage (au cas où on revient en arrière) + _scale = savedScale; + _offset = savedOffset; + // AJOUT DE LA DECOUPE ET DU REDRESSEMENT GÉOMÉTRIQUE PHYSIQUE final croppedImagePath = await _cropService.cropToSquare( widget.imagePath, cropRect, - rotationDegrees: _rotation, // On transmet la rotation à la jauge haute précision + rotationDegrees: _rotation, ); - // L'image sortant du service étant désormais un carré physique parfait (1:1), - // le centre de la cible se trouve précisément au milieu (0.5, 0.5) const targetCenterX = 0.5; const targetCenterY = 0.5; @@ -409,13 +418,13 @@ class _CropScreenState extends State { context, MaterialPageRoute( builder: (_) => AnalysisScreen( - imagePath: croppedImagePath, // On injecte le fichier carré nettoyé + imagePath: croppedImagePath, targetType: widget.targetType, initialCenterX: targetCenterX, initialCenterY: targetCenterY, - cropScale: 1.0, // Réinitialisé car la texture est déjà recadrée à la bonne échelle - cropOffset: Offset.zero, // Réinitialisé car le fichier est déjà parfaitement centré - cropRotation: 0.0, // Réinitialisé car les pixels ont déjà subi la rotation matricielle + cropScale: 1.0, + cropOffset: Offset.zero, + cropRotation: 0.0, ), ), );