*better-rer* character scaling algorithm

This commit is contained in:
Crystalwarrior 2019-09-20 17:04:44 +03:00
parent 6dd0845f1c
commit 520c4f5947

View File

@ -234,19 +234,19 @@ QPixmap AOCharMovie::get_pixmap(QImage image)
auto aspect_ratio = Qt::KeepAspectRatio; auto aspect_ratio = Qt::KeepAspectRatio;
auto transform_mode = Qt::SmoothTransformation; auto transform_mode = Qt::SmoothTransformation;
if (f_pixmap.size().width() > this->size().width() && f_pixmap.size().height() <= this->size().height()) if (f_pixmap.size().width() > this->size().width() || f_pixmap.size().height() > this->size().height())
{ {
f_pixmap = f_pixmap.scaledToHeight(this->height(), transform_mode); f_pixmap = f_pixmap.scaledToHeight(this->height(), transform_mode);
} }
else if (f_pixmap.size().height() > this->size().height()) // else if (f_pixmap.size().height() > this->size().height())
{ // {
f_pixmap = f_pixmap.scaledToWidth(this->width(), transform_mode); // f_pixmap = f_pixmap.scaledToWidth(this->width(), transform_mode);
} // }
else else
{ {
f_pixmap = f_pixmap.scaled(this->width(), this->height(), aspect_ratio, transform_mode); f_pixmap = f_pixmap.scaled(this->width(), this->height(), aspect_ratio, transform_mode);
} }
this->move((f_w - f_pixmap.width())/2, (f_h - f_pixmap.height())/2); this->move((f_w - f_pixmap.width())/2, (f_pixmap.height() - f_h)); //Always center horizontally, always put at the bottom vertically
this->resize(f_pixmap.size()); this->resize(f_pixmap.size());
return f_pixmap; return f_pixmap;