mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-22 06:08:07 +00:00
Fix factor computation to detect non-standard size for a thumbnail.
This commit is contained in:
parent
14efd86660
commit
06eedaaf6f
2 changed files with 33 additions and 27 deletions
|
|
@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
## Fixed
|
||||
- Fix using only username in URI handlers.
|
||||
- Chat flickering on load.
|
||||
- Portait thumbnails.
|
||||
- Color of busy indicator when the chat is loading.
|
||||
- Incoming ephemerals weren't removed without reloading chat rooms.
|
||||
- Update SDK to 5.2.42
|
||||
|
|
|
|||
|
|
@ -184,33 +184,38 @@ void ContentModel::createThumbnail (const bool& force) {
|
|||
QPainter painter(&image);
|
||||
painter.drawImage(0, 0, originalImage);
|
||||
//--------------------
|
||||
QImage thumbnail = image.scaled(
|
||||
Constants::ThumbnailImageFileWidth, Constants::ThumbnailImageFileHeight,
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation
|
||||
);
|
||||
|
||||
if (rotation != 0) {
|
||||
QTransform transform;
|
||||
if (rotation == 3 || rotation == 4)
|
||||
transform.rotate(180);
|
||||
else if (rotation == 5 || rotation == 6)
|
||||
transform.rotate(90);
|
||||
else if (rotation == 7 || rotation == 8)
|
||||
transform.rotate(-90);
|
||||
thumbnail = thumbnail.transformed(transform);
|
||||
if (rotation == 2 || rotation == 4 || rotation == 5 || rotation == 7)
|
||||
thumbnail = thumbnail.mirrored(true, false);
|
||||
}
|
||||
QString uuid = QUuid::createUuid().toString();
|
||||
id = QStringLiteral("%1.jpg").arg(uuid.mid(1, uuid.length() - 2));
|
||||
|
||||
if (!thumbnail.save(QString::fromStdString(Paths::getThumbnailsDirPath()) + id , "jpg", 100)) {
|
||||
qWarning() << QStringLiteral("Unable to create thumbnail of: `%1`.").arg(path);
|
||||
}else{
|
||||
appdata.mData[path] = id;
|
||||
mAppData.mData[path] = id;
|
||||
if(mChatMessageModel)
|
||||
mChatMessageModel->getChatMessage()->setAppdata(appdata.toString().toStdString());
|
||||
double factor = image.width() / (double)image.height();
|
||||
if(factor < 0.2 || factor > 5){
|
||||
qInfo() << QStringLiteral("Cannot create thumbnails because size factor (%1) is too low/much of: `%2`.").arg(factor).arg(path);
|
||||
}else {
|
||||
QImage thumbnail = image.scaled(
|
||||
Constants::ThumbnailImageFileWidth, Constants::ThumbnailImageFileHeight,
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation
|
||||
);
|
||||
|
||||
if (rotation != 0) {
|
||||
QTransform transform;
|
||||
if (rotation == 3 || rotation == 4)
|
||||
transform.rotate(180);
|
||||
else if (rotation == 5 || rotation == 6)
|
||||
transform.rotate(90);
|
||||
else if (rotation == 7 || rotation == 8)
|
||||
transform.rotate(-90);
|
||||
thumbnail = thumbnail.transformed(transform);
|
||||
if (rotation == 2 || rotation == 4 || rotation == 5 || rotation == 7)
|
||||
thumbnail = thumbnail.mirrored(true, false);
|
||||
}
|
||||
QString uuid = QUuid::createUuid().toString();
|
||||
id = QStringLiteral("%1.jpg").arg(uuid.mid(1, uuid.length() - 2));
|
||||
|
||||
if (!thumbnail.save(QString::fromStdString(Paths::getThumbnailsDirPath()) + id , "jpg", 100)) {
|
||||
qWarning() << QStringLiteral("Unable to create thumbnail of: `%1`.").arg(path);
|
||||
}else{
|
||||
appdata.mData[path] = id;
|
||||
mAppData.mData[path] = id;
|
||||
if(mChatMessageModel)
|
||||
mChatMessageModel->getChatMessage()->setAppdata(appdata.toString().toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue