mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
parent
06fd9e9ec9
commit
c2fcbd64d3
1 changed files with 11 additions and 12 deletions
|
@ -182,22 +182,21 @@ void QSize::scale(const QSize &s, Qt::AspectRatioMode mode)
|
||||||
if (mode == Qt::IgnoreAspectRatio || wd == 0 || ht == 0) {
|
if (mode == Qt::IgnoreAspectRatio || wd == 0 || ht == 0) {
|
||||||
wd = s.wd;
|
wd = s.wd;
|
||||||
ht = s.ht;
|
ht = s.ht;
|
||||||
} else if (mode == Qt::KeepAspectRatio) {
|
} else {
|
||||||
int rw = s.ht * wd / ht;
|
bool useHeight;
|
||||||
if (rw <= s.wd) {
|
qint64 rw = qint64(s.ht) * qint64(wd) / qint64(ht);
|
||||||
wd = rw;
|
|
||||||
ht = s.ht;
|
if (mode == Qt::KeepAspectRatio) {
|
||||||
} else {
|
useHeight = (rw <= s.wd);
|
||||||
ht = s.wd * ht / wd;
|
} else { // mode == Qt::KeepAspectRatioByExpanding
|
||||||
wd = s.wd;
|
useHeight = (rw >= s.wd);
|
||||||
}
|
}
|
||||||
} else { // mode == Qt::KeepAspectRatioByExpanding
|
|
||||||
int rw = s.ht * wd / ht;
|
if (useHeight) {
|
||||||
if (rw >= s.wd) {
|
|
||||||
wd = rw;
|
wd = rw;
|
||||||
ht = s.ht;
|
ht = s.ht;
|
||||||
} else {
|
} else {
|
||||||
ht = s.wd * ht / wd;
|
ht = qint32(qint64(s.wd) * qint64(ht) / qint64(wd));
|
||||||
wd = s.wd;
|
wd = s.wd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue