Viewer has thumbnail mode now

This commit is contained in:
2025-08-01 21:56:59 +02:00
parent a70c4957fd
commit c6606931de

View File

@ -1,6 +1,6 @@
import dearpygui.dearpygui as dpg
import numpy as np
from PIL import Image
from .pipeline_stage_widget import PipelineStageWidget
@ -27,6 +27,18 @@ class PipelineStageViewer(PipelineStageWidget):
self.needs_update = True
def on_pipeline_data(self, img):
# Resize if needed
h, w, _ = img.shape
max_dim = 500
scale = min(1.0, max_dim / w, max_dim / h)
if scale < 1.0:
# convert to 0255 uint8, resize with PIL, back to float32 [01]
pil = Image.fromarray((img * 255).astype(np.uint8), mode="RGBA")
new_w, new_h = int(w * scale), int(h * scale)
pil = pil.resize((new_w, new_h), Image.LANCZOS)
img = np.asarray(pil).astype(np.float32) / 255.0
w, h = new_w, new_h
self.img = img
self.needs_update = True
@ -54,7 +66,7 @@ class PipelineStageViewer(PipelineStageWidget):
avail_w = win_w
avail_h = win_h
scale = min(avail_w / w, avail_h / h, 1.0)
scale = min(avail_w / w, avail_h / h) #, 1.0)
disp_w = int(w * scale)
disp_h = int(h * scale)