Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
柴进
/
GoogleNanoBananaApp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
68235b13
authored
2026-02-28 10:56:31 +0800
by
柴进
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
处理mac打包后粘贴图片缩略图不可见的问题
1 parent
7ad013ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
12 deletions
image_generator.py
image_generator.py
View file @
68235b1
...
...
@@ -1865,21 +1865,41 @@ class ImageGeneratorWindow(QMainWindow):
temp_file_path
=
temp_dir
/
f
"clipboard_{timestamp}{file_extension}"
# 尝试多种保存方式,确保兼容性
self
.
logger
.
info
(
f
"QImage信息: {image.width()}x{image.height()}, format={image.format()}, isNull={image.isNull()}"
)
success
=
False
# 方法1: 先转换为 RGB32 格式再保存(避免格式不兼容导致保存异常)
try
:
# 方法1: 指定PNG格式
success
=
image
.
save
(
str
(
temp_file_path
),
"PNG"
)
self
.
logger
.
info
(
f
"方法1保存结果: {success}"
)
except
:
normalized
=
image
.
convertToFormat
(
QImage
.
Format
.
Format_ARGB32
)
success
=
normalized
.
save
(
str
(
temp_file_path
),
"PNG"
)
self
.
logger
.
info
(
f
"方法1(ARGB32转换)保存结果: {success}"
)
except
Exception
as
e
:
self
.
logger
.
warning
(
f
"方法1保存失败: {e}"
)
# 方法2: 直接保存原始格式
if
not
success
:
try
:
# 方法2: 自动格式
success
=
image
.
save
(
str
(
temp_file_path
))
self
.
logger
.
info
(
f
"方法2保存结果: {success}"
)
except
:
# 方法3: 转换格式再保存
converted_image
=
QImage
(
image
)
success
=
converted_image
.
save
(
str
(
temp_file_path
),
"PNG"
)
self
.
logger
.
info
(
f
"方法3保存结果: {success}"
)
success
=
image
.
save
(
str
(
temp_file_path
),
"PNG"
)
self
.
logger
.
info
(
f
"方法2(原始格式)保存结果: {success}"
)
except
Exception
as
e
:
self
.
logger
.
warning
(
f
"方法2保存失败: {e}"
)
# 方法3: 通过 QPixmap 中转保存
if
not
success
:
try
:
pixmap
=
QPixmap
.
fromImage
(
image
)
success
=
pixmap
.
save
(
str
(
temp_file_path
),
"PNG"
)
self
.
logger
.
info
(
f
"方法3(QPixmap中转)保存结果: {success}"
)
except
Exception
as
e
:
self
.
logger
.
warning
(
f
"方法3保存失败: {e}"
)
# 验证保存的文件确实可被加载为缩略图
if
success
and
temp_file_path
.
exists
():
file_size
=
temp_file_path
.
stat
()
.
st_size
self
.
logger
.
info
(
f
"保存文件大小: {file_size} bytes"
)
if
file_size
==
0
:
self
.
logger
.
error
(
"保存的文件为空(0字节)"
)
success
=
False
if
success
and
temp_file_path
.
exists
():
self
.
uploaded_images
.
append
(
str
(
temp_file_path
))
...
...
Please
register
or
sign in
to post a comment