QQ图片20241016012203.png (389.93 KB, 下载次数: 0)
下载附件
2024-10-16 01:23 上传
QQ图片20241016012153.png (595.77 KB, 下载次数: 0)
下载附件
2024-10-16 01:23 上传
`$S{3R]GCOL`UW6RX(9Y$]O.png (513.38 KB, 下载次数: 0)
下载附件
2024-10-16 01:23 上传
九宫格
[Python] 纯文本查看 复制代码import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout, QHBoxLayout, QFileDialog, QMessageBox
from PyQt5.QtGui import QPixmap, QPainter, QPen, QImage
from PyQt5.QtCore import Qt, QPoint, QRect
from datetime import datetime
class ImageSplitter(QWidget):
def __init__(self):
super().__init__()
self.initUI()
self.image = None
self.image_rect = None
self.drag_start = None
self.scale = 1.0
def initUI(self):
self.setWindowTitle('微信朋友圈九宫格图片分割工具by林林柒')
self.setGeometry(100, 100, 650, 700)
self.image_frame = QLabel(self)
self.image_frame.setFixedSize(600, 600)
self.image_frame.setAlignment(Qt.AlignCenter)
self.image_frame.setStyleSheet("border: 1px solid black;")
self.info_label = QLabel(self)
self.info_label.setAlignment(Qt.AlignCenter)
self.note_label = QLabel("备注:可以拖入图片或导入图片,可以拖动和鼠标滚轮缩放进行分割", self)
self.note_label.setAlignment(Qt.AlignCenter)
import_button = QPushButton('导入图片', self)
import_button.clicked.connect(self.importImage)
split_button = QPushButton('分割图片', self)
split_button.clicked.connect(self.splitImage)
button_layout = QHBoxLayout()
button_layout.addWidget(import_button)
button_layout.addWidget(split_button)
layout = QVBoxLayout()
layout.addWidget(self.image_frame)
layout.addWidget(self.info_label)
layout.addWidget(self.note_label)
layout.addLayout(button_layout)
self.setLayout(layout)
self.setAcceptDrops(True)
def importImage(self):
file_name, _ = QFileDialog.getOpenFileName(self, "选择图片", "", "图片文件 (*.png *.jpg *.bmp)")
if file_name:
self.loadImage(file_name)
def loadImage(self, file_name):
self.image = QImage(file_name)
if self.image.width() 0:
self.scale *= 1.1
else:
self.scale /= 1.1
self.image_rect.setWidth(int(self.image.width() * self.scale))
self.image_rect.setHeight(int(self.image.height() * self.scale))
self.updateImage()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = ImageSplitter()
ex.show()
sys.exit(app.exec_())
圆形
[Python] 纯文本查看 复制代码import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QVBoxLayout, QHBoxLayout, QFileDialog, QMessageBox
from PyQt5.QtGui import QPixmap, QPainter, QPen, QImage, QColor, QBrush
from PyQt5.QtCore import Qt, QPoint, QRect
from datetime import datetime
class ImageSplitter(QWidget):
def __init__(self):
super().__init__()
self.initUI()
self.image = None
self.image_rect = None
self.drag_start = None
self.scale = 1.0
def initUI(self):
self.setWindowTitle('微信朋友圈九宫格图片分割工具by林林柒')
self.setGeometry(100, 100, 650, 700)
self.image_frame = QLabel(self)
self.image_frame.setFixedSize(600, 600)
self.image_frame.setAlignment(Qt.AlignCenter)
self.image_frame.setStyleSheet("border: 1px solid black;")
self.info_label = QLabel(self)
self.info_label.setAlignment(Qt.AlignCenter)
self.note_label = QLabel("备注:可以拖入图片或导入图片,可以拖动和鼠标滚轮缩放进行分割", self)
self.note_label.setAlignment(Qt.AlignCenter)
import_button = QPushButton('导入图片', self)
import_button.clicked.connect(self.importImage)
split_button = QPushButton('分割图片', self)
split_button.clicked.connect(self.splitImage)
button_layout = QHBoxLayout()
button_layout.addWidget(import_button)
button_layout.addWidget(split_button)
layout = QVBoxLayout()
layout.addWidget(self.image_frame)
layout.addWidget(self.info_label)
layout.addWidget(self.note_label)
layout.addLayout(button_layout)
self.setLayout(layout)
self.setAcceptDrops(True)
def importImage(self):
file_name, _ = QFileDialog.getOpenFileName(self, "选择图片", "", "图片文件 (*.png *.jpg *.bmp)")
if file_name:
self.loadImage(file_name)
def loadImage(self, file_name):
self.image = QImage(file_name)
if self.image.width() 0:
self.scale *= 1.1
else:
self.scale /= 1.1
self.image_rect.setWidth(int(self.image.width() * self.scale))
self.image_rect.setHeight(int(self.image.height() * self.scale))
self.updateImage()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = ImageSplitter()
ex.show()
sys.exit(app.exec_())