diff --git a/pewpew/graphics/export.py b/pewpew/graphics/export.py index 6efd0016..eea571d2 100644 --- a/pewpew/graphics/export.py +++ b/pewpew/graphics/export.py @@ -142,6 +142,7 @@ def generate_laser_image( colorbar: bool = True, raw: bool = False, size: QtCore.QSize | None = None, + scale: float = 1.0, dpi: int = 96, ) -> QtGui.QImage: data = laser.get(element, calibrate=options.calibrate, flat=True) @@ -219,7 +220,7 @@ def generate_laser_image( # Draw the scale-bar if scalebar_alignment is not None: x0, x1, y0, y1 = laser.extent - scale = (x1 - x0) / pixmap.width() + scale = (x1 - x0) / pixmap.width() / scale paint_scalebar(painter, xh * 10.0, text_bounds, scalebar_alignment, scale) painter.end() @@ -243,6 +244,7 @@ def generate_rgb_laser_image( raw: bool = False, subtractive: bool = False, size: QtCore.QSize | None = None, + scale: float = 1.0, dpi: int = 96, ) -> QtGui.QImage: data = np.zeros((*laser.shape[:2], 3)) @@ -319,7 +321,7 @@ def generate_rgb_laser_image( # Draw the scale-bar if scalebar_alignment is not None: x0, x1, y0, y1 = laser.extent - scale = (x1 - x0) / image.rect().width() + scale = (x1 - x0) / image.rect().width() / scale paint_scalebar(painter, xh * 10.0, text_bounds, scalebar_alignment, scale) # Draw the color Venn diff --git a/pewpew/widgets/exportdialogs.py b/pewpew/widgets/exportdialogs.py index 386ba510..fc821ed7 100644 --- a/pewpew/widgets/exportdialogs.py +++ b/pewpew/widgets/exportdialogs.py @@ -228,6 +228,12 @@ def updateSizeLabel(self) -> None: def scale(self) -> int: return self.spin_scale.value() + def imageSize(self) -> QtCore.QSize: + return QtCore.QSize( + self.base_size.width() * self.spin_scale.value(), + self.base_size.height() * self.spin_scale.value(), + ) + def dpi(self) -> int: return int(self.le_dpi.text()) @@ -494,7 +500,6 @@ def __init__( apparent_size.setWidth(int(apparent_size.width() * aspect)) elif aspect < 1: apparent_size.setHeight(int(apparent_size.height() / aspect)) - print(aspect, apparent_size, item.imageSize()) if isinstance(item, RGBLaserImageItem): options = [RBGOptionsBox(apparent_size, item.current_elements)] @@ -614,6 +619,7 @@ def export( assert graphics_options is not None if isinstance(option, RBGOptionsBox): size = option.imageSize() + scale = option.scale() if any(x in laser.elements for x in option.elements()): image = generate_rgb_laser_image( laser, @@ -626,14 +632,16 @@ def export( venn_alignment=option.vennAlignment(), raw=option.isRaw(), size=size, + scale=scale, dpi=option.dpi(), ) image.setDotsPerMeterX(option.dpi() * 39.37007874) image.setDotsPerMeterY(option.dpi() * 39.37007874) image.save(str(path.absolute())) else: + size = option.imageSize() + scale = option.scale() if element is not None and element in laser.elements: - size = option.imageSize() image = generate_laser_image( laser, element, @@ -643,6 +651,7 @@ def export( colorbar=option.useColorbar(), raw=option.isRaw(), size=size, + scale=scale, dpi=option.dpi(), ) image.setDotsPerMeterX(option.dpi() * 39.37007874)