Fix issue #909, Have ratio correction first and then scale (#1047)

This commit is contained in:
LordGrey 2020-10-18 19:08:27 +02:00 committed by GitHub
parent 8f991001c1
commit 83b8a800d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -234,12 +234,6 @@ namespace hyperion {
midPointsY.erase(std::unique(midPointsY.begin(), midPointsY.end()), midPointsY.end());
QSize gridSize( midPointsX.size(), midPointsY.size() );
//Debug(_log, "LED layout grid size: %dx%d", gridSize.width(), gridSize.height());
// Limit to 80px for performance reasons
const int pl = 80;
if(gridSize.width() > pl || gridSize.height() > pl)
gridSize.scale(pl, pl, Qt::KeepAspectRatio);
// Correct the grid in case it is malformed in width vs height
// Expected is at least 50% of width <-> height
@ -248,6 +242,13 @@ namespace hyperion {
else if((gridSize.width() / gridSize.height()) < 0.5)
gridSize.setWidth(qMax(1,gridSize.height()/2));
// Limit to 80px for performance reasons
const int pl = 80;
if(gridSize.width() > pl || gridSize.height() > pl)
{
gridSize.scale(pl, pl, Qt::KeepAspectRatio);
}
return gridSize;
}
};