v0.9.16
This commit is contained in:
@@ -13,7 +13,7 @@ Classes:
|
||||
import os
|
||||
import logging
|
||||
import math
|
||||
from PySide6.QtCore import QThread, Signal, QMutex, QWaitCondition, QObject, Qt
|
||||
from PySide6.QtCore import QThread, Signal, QMutex, QWaitCondition, QObject, Qt, QSize
|
||||
from PySide6.QtGui import QImage, QImageReader, QPixmap, QTransform
|
||||
from xmpmanager import XmpManager
|
||||
from constants import (
|
||||
@@ -688,19 +688,37 @@ class ImageController(QObject):
|
||||
if self.pixmap_original.isNull():
|
||||
return QPixmap()
|
||||
|
||||
transform = QTransform().rotate(self.rotation)
|
||||
transformed_pixmap = self.pixmap_original.transformed(
|
||||
transform,
|
||||
Qt.SmoothTransformation
|
||||
)
|
||||
new_size = transformed_pixmap.size() * self.zoom_factor
|
||||
scaled_pixmap = transformed_pixmap.scaled(new_size, Qt.KeepAspectRatio,
|
||||
Qt.SmoothTransformation)
|
||||
# Ensure pixmap_original is a valid, independent copy before transforming
|
||||
temp_pixmap = QPixmap(self.pixmap_original)
|
||||
if temp_pixmap.isNull():
|
||||
return QPixmap()
|
||||
|
||||
# Use rotated() which returns a new QTransform, potentially safer
|
||||
transform = QTransform() # Initialize to identity transform
|
||||
if self.rotation != 0:
|
||||
transform = QTransform().rotated(float(self.rotation))
|
||||
|
||||
transformed_pixmap = temp_pixmap.transformed(
|
||||
transform, Qt.TransformationMode.SmoothTransformation)
|
||||
|
||||
# Calculate new size, explicitly converting QSizeF to QSize
|
||||
new_size_f = transformed_pixmap.size() * self.zoom_factor
|
||||
new_size = QSize(int(new_size_f.width()), int(new_size_f.height()))
|
||||
|
||||
scaled_pixmap = transformed_pixmap.scaled(
|
||||
new_size, Qt.AspectRatioMode.KeepAspectRatio,
|
||||
Qt.TransformationMode.SmoothTransformation)
|
||||
|
||||
if self.flip_h:
|
||||
scaled_pixmap = scaled_pixmap.transformed(QTransform().scale(-1, 1))
|
||||
t_flip_h = QTransform()
|
||||
t_flip_h.scale(-1, 1)
|
||||
scaled_pixmap = scaled_pixmap.transformed(
|
||||
t_flip_h, Qt.TransformationMode.SmoothTransformation)
|
||||
if self.flip_v:
|
||||
scaled_pixmap = scaled_pixmap.transformed(QTransform().scale(1, -1))
|
||||
t_flip_v = QTransform()
|
||||
t_flip_v.scale(1, -1)
|
||||
scaled_pixmap = scaled_pixmap.transformed(
|
||||
t_flip_v, Qt.TransformationMode.SmoothTransformation)
|
||||
|
||||
return scaled_pixmap
|
||||
|
||||
|
||||
Reference in New Issue
Block a user