2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-04 00:25:17 +00:00

Refactor image transformation interfaces.

This commit is contained in:
John Preston
2022-01-21 15:31:39 +03:00
parent a9a6d8a568
commit 3ff17a8789
55 changed files with 546 additions and 789 deletions

View File

@@ -320,7 +320,11 @@ void PeerData::paintUserpic(
int y,
int size) const {
if (const auto userpic = currentUserpic(view)) {
p.drawPixmap(x, y, userpic->pixCircled(size, size));
const auto circled = Images::Option::RoundCircle;
p.drawPixmap(
x,
y,
userpic->pix(size, size, { .options = circled }));
} else {
ensureEmptyUserpic()->paint(p, x, y, x + size + x, size);
}
@@ -380,10 +384,14 @@ QPixmap PeerData::genUserpic(
std::shared_ptr<Data::CloudImageView> &view,
int size) const {
if (const auto userpic = currentUserpic(view)) {
return userpic->pixCircled(size, size);
const auto circle = Images::Option::RoundCircle;
return userpic->pix(size, size, { .options = circle });
}
auto result = QImage(QSize(size, size) * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(cRetinaFactor());
const auto ratio = style::DevicePixelRatio();
auto result = QImage(
QSize(size, size) * ratio,
QImage::Format_ARGB32_Premultiplied);
result.setDevicePixelRatio(ratio);
result.fill(Qt::transparent);
{
Painter p(&result);
@@ -404,15 +412,13 @@ QImage PeerData::generateUserpicImage(
ImageRoundRadius radius) const {
if (const auto userpic = currentUserpic(view)) {
const auto options = (radius == ImageRoundRadius::Ellipse)
? (Images::Option::RoundedAll | Images::Option::Circled)
? Images::Option::RoundCircle
: (radius == ImageRoundRadius::None)
? Images::Options()
: (Images::Option::RoundedAll | Images::Option::RoundedSmall);
? Images::Option()
: Images::Option::RoundSmall;
return userpic->pixNoCache(
size,
size,
Images::Option::Smooth | options
).toImage();
{ size, size },
{ .options = options }).toImage();
}
auto result = QImage(
QSize(size, size),