Skip to content

Commit

Permalink
Scale the captured image to fit the preview
Browse files Browse the repository at this point in the history
  • Loading branch information
vietanhdev committed Dec 13, 2024
1 parent ad5a9a1 commit f0089d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions llama_assistant/screen_capture_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def __init__(self, parent: "LlamaAssistantApp"):
self.preview_label = QLabel()
self.preview_label.setMinimumSize(QSize(400, 250)) # Bigger preview
self.preview_label.setAlignment(Qt.AlignCenter)
self.preview_label.setStyleSheet("background-color: transparent;")
self.preview_label.setScaledContents(True) # Make content scale to fit label
preview_layout.addWidget(self.preview_label)

# Modern button styling
Expand Down Expand Up @@ -243,8 +245,7 @@ def _do_capture(self, start_point, end_point, restore_visibility=True):
print(f"Captured region saved at '{config.ocr_tmp_file}'.")

# Update preview label with captured image
preview_pixmap = pixmap.scaled(400, 250, Qt.KeepAspectRatio, Qt.SmoothTransformation)
self.preview_label.setPixmap(preview_pixmap)
self.preview_label.setPixmap(pixmap)

# Restore visibility if needed
if restore_visibility:
Expand Down

0 comments on commit f0089d2

Please sign in to comment.