Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions ui/image/image_prepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,17 @@ std::array<QImage, 4> PrepareCorners(
result.format = reader.format().toLower();
result.animated = reader.supportsAnimation()
&& (reader.imageCount() > 1);
result.image = QImage(size, QImage::Format_ARGB32_Premultiplied);
Copy link
Copy Markdown
Contributor

@ilya-fedin ilya-fedin Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which format we're fixing for? If it's JPEG, I checked QJpegHandler code and it always re-allocates the image if either size or format isn't expected. And it never expects QImage::Format_ARGB32_Premultiplied. So if we're fixing for jpeg, this has no sense.

if (result.image.isNull()) {
return {};
}
result.image.fill(Qt::transparent);
if (!reader.read(&result.image) || result.image.isNull()) {
return {};
}
if (reader.error() != QImageReader::UnknownError) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has no sense, if there's any error, QImageReader::read checked in the previous condition will return false

return {};
}
return result;
}

Expand Down Expand Up @@ -1251,9 +1259,7 @@ QImage Prepare(QImage image, int w, int h, const PrepareArgs &args) {
image.setDevicePixelRatio(ratio);
auto result = QImage(outer, QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(ratio);
if (args.options & Images::Option::TransparentBackground) {
result.fill(Qt::transparent);
}
result.fill(Qt::transparent);
{
QPainter p(&result);
if (!(args.options & Images::Option::TransparentBackground)) {
Expand Down