Skip to content

Commit

Permalink
Update image masking code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Laurent committed Dec 25, 2024
1 parent 09441a7 commit 3628a2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions fmu_manipulation_toolbox/gui.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os.path
import sys
from .version import __version__ as version
from PyQt6.QtCore import Qt, QObject, QUrl, pyqtSignal, QDir, QSize, QRect
from PyQt6.QtCore import Qt, QObject, QUrl, pyqtSignal, QDir, QSize, QPoint
from PyQt6.QtWidgets import (QApplication, QWidget, QGridLayout, QLabel, QLineEdit, QPushButton, QFileDialog,
QTextBrowser, QInputDialog, QMenu)
from PyQt6.QtGui import (QPixmap, QImage, QFont, QTextCursor, QIcon, QDesktopServices, QAction, QPainter, QColor)
Expand Down Expand Up @@ -71,19 +71,19 @@ def set_image(self, filename=None):
filename = os.path.join(os.path.dirname(__file__), "resources", "fmu.png")

base_image = QImage(filename).scaled(self.WIDTH, self.HEIGHT, Qt.AspectRatioMode.IgnoreAspectRatio,
Qt.TransformationMode.SmoothTransformation)
Qt.TransformationMode.SmoothTransformation)
mask_filename = os.path.join(os.path.dirname(__file__), "resources", "mask.png")
mask_image = QImage(mask_filename).scaled(self.WIDTH, self.HEIGHT, Qt.AspectRatioMode.IgnoreAspectRatio,
Qt.TransformationMode.SmoothTransformation)
rounded = QImage(QSize(self.WIDTH, self.HEIGHT), QImage.Format.Format_ARGB32)
rounded.fill(QColor(0, 0, 0, 0))
mask_image = QImage(mask_filename)
rounded_image = QImage(self.WIDTH, self.HEIGHT, QImage.Format.Format_ARGB32)
rounded_image.fill(QColor(0, 0, 0, 0))
painter = QPainter()
painter.begin(rounded)
painter.begin(rounded_image)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.drawImage(QRect(0, 0, self.WIDTH, self.HEIGHT), base_image)
painter.drawImage(QRect(0, 0, self.WIDTH, self.HEIGHT), mask_image)
painter.drawImage(QPoint(0, 0), base_image)
painter.drawImage(QPoint(0, 0), mask_image)
painter.end()
pixmap = QPixmap.fromImage(rounded)
pixmap = QPixmap.fromImage(rounded_image)

self.setPixmap(pixmap)


Expand Down
Binary file modified fmu_manipulation_toolbox/resources/mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3628a2a

Please sign in to comment.