mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-10 12:03:18 +02:00
avatar: fix image cropping
Take into consideration the vertical margin when cropping the image. Change-Id: I140c96f54d2c1ae732bd104fb21ad04d66d97e9a
This commit is contained in:
parent
519871e458
commit
89bed2bf85
1 changed files with 10 additions and 3 deletions
|
@ -540,13 +540,20 @@ Utils::getCirclePhoto(const QImage original, int sizePhoto)
|
|||
Qt::KeepAspectRatioByExpanding,
|
||||
Qt::SmoothTransformation)
|
||||
.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
int margin = 0;
|
||||
int marginX = 0;
|
||||
int marginY = 0;
|
||||
|
||||
if (scaledPhoto.width() > sizePhoto) {
|
||||
margin = (scaledPhoto.width() - sizePhoto) / 2;
|
||||
marginX = (scaledPhoto.width() - sizePhoto) / 2;
|
||||
}
|
||||
if (scaledPhoto.height() > sizePhoto) {
|
||||
marginY = (scaledPhoto.height() - sizePhoto) / 2;
|
||||
}
|
||||
|
||||
painter.drawEllipse(0, 0, sizePhoto, sizePhoto);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
painter.drawImage(0, 0, scaledPhoto, margin, 0);
|
||||
painter.drawImage(0, 0, scaledPhoto, marginX, marginY);
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue