def createImageItem(self, qimg, qPdfView): qimg = self.applyTheme(qimg) pixImg = QPixmap() pixImg.convertFromImage(qimg) qPdfView.setPixmap(pixImg) return pixImg
def drawInvertedSelection(self, x=0, y=0, tilemap_x=0, tilemap_y=0, tilemap_w=32, tilemap_h=32): offset = 1 clip_space_border = QRect(tilemap_x, tilemap_y, tilemap_w, tilemap_h) clip_space_fill = QRect(tilemap_x + 3, tilemap_y + 3, tilemap_w - 6, tilemap_h - 6) clipped_border = self._tilemaps[self._current_tilemap].copy( clip_space_border) clipped_fill = self._tilemaps[self._current_tilemap].copy( clip_space_fill) image = clipped_border.toImage() image.invertPixels() invert_selection = QPixmap() invert_selection.convertFromImage(image) tile_pos = self.findTilePos(x, y) if self._current_selection_border is not None and self._current_selection_fill is not None: self._scene.removeItem(self._current_selection_border) self._scene.removeItem(self._current_selection_fill) self._current_selection_border = self._scene.addPixmap( invert_selection) self._current_selection_fill = self._scene.addPixmap(clipped_fill) self._current_selection_border.setPos(tile_pos[0], tile_pos[1]) self._current_selection_fill.setPos(tile_pos[0] + 3, tile_pos[1] + 3)
class ColorPicker(QLabel): def __init__(self, radius): super().__init__() self.setFixedSize(2*radius, 2*radius) self.qc_Color = QColor(0, 0, 0, 255) self.radius = radius self.qpm_Image = QPixmap() #Create the image qi_image = QImage(self.width(), self.height(), QImage.Format_RGB32) for i in range(self.width()): for j in range(self.height()): color = QColor(0, 0, 0, 255) h = (np.arctan2(i - self.radius, j - self.radius) + np.pi) / (2. * np.pi) s = np.sqrt(np.power(i - self.radius, 2) + np.power(j - self.radius, 2)) / self.radius v = 1.0 if s < 1.0: color.setHsvF(h, s, v, 1.0) qi_image.setPixelColor(i, j, color) self.qpm_Image.convertFromImage(qi_image) self.setPixmap(self.qpm_Image) # self.showFullScreen() def mousePressEvent(self, mouseevent: QMouseEvent): super().mouseMoveEvent(mouseevent) if mouseevent.button() == Qt.LeftButton: x = mouseevent.x() y = mouseevent.y() h = (np.arctan2(x - self.radius, y - self.radius) + np.pi) / (2. * np.pi) s = np.sqrt(np.power(x - self.radius, 2) + np.power(y - self.radius, 2)) / self.radius v = 1.0 if s < 1.0: self.qc_Color.setHsvF(h, s, v, 1.0) # Message box used for the debug of the color picker # QMessageBox.warning(self, "Color", "Value(" + str(self.qc_Color.toRgb().red()) + ", " + str(self.qc_Color.toRgb().green()) + ", " + str(self.qc_Color.toRgb().blue()) + ")") def get_color(self): return self.qc_Color
def _set_icon_label(self, icon_info, icon_label): image, mime, file_info = icon_info pixmap = None if image: pixmap = QPixmap(self.FILE_LIST_ICON_SIZE, self.FILE_LIST_ICON_SIZE) pixmap.convertFromImage(image) elif mime: icon = self._get_icon(mime) if icon: pixmap = icon.pixmap( self.FILE_LIST_ICON_SIZE, self.FILE_LIST_ICON_SIZE) if not pixmap or pixmap.isNull(): icon = QFileIconProvider().icon(file_info) pixmap = icon.pixmap( self.FILE_LIST_ICON_SIZE, self.FILE_LIST_ICON_SIZE) if pixmap and not pixmap.isNull(): icon_label.setPixmap(pixmap) icon_label.setScaledContents(True) icon_label.setFixedSize( self.FILE_LIST_ICON_SIZE, self.FILE_LIST_ICON_SIZE) icon_label.setAlignment(Qt.AlignCenter)
def updateImage(self, data: QImage): img = QPixmap() img.convertFromImage(data) self.video_frame.setPixmap(img)