Skip to content

Commit

Permalink
Fixed potential scaling happening for maps used as tilesets
Browse files Browse the repository at this point in the history
When determining the size of the tileset image, the map's layer offsets
were not taken into account. They were however taken into account when
determining the scale of the map. In effect, maps with layers at an
offset would get scaled down to fit on the too small image.

Closes mapeditor#2843
  • Loading branch information
bjorn committed Jun 23, 2020
1 parent 5d2169d commit cbf0cbd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libtiled/minimaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ MiniMapRenderer::~MiniMapRenderer()

QSize MiniMapRenderer::mapSize() const
{
return mRenderer->mapBoundingRect().size();
QRect mapBoundingRect = mRenderer->mapBoundingRect();
QSize mapSize = mapBoundingRect.size();

QMargins margins = mMap->computeLayerOffsetMargins();
mapSize.setWidth(mapSize.width() + margins.left() + margins.right());
mapSize.setHeight(mapSize.height() + margins.top() + margins.bottom());

return mapSize;
}

QImage MiniMapRenderer::render(QSize size, RenderFlags renderFlags) const
Expand Down Expand Up @@ -140,7 +147,7 @@ static void extendMapRect(QRect &mapBoundingRect, const MapRenderer &renderer)
mapBoundingRect = rect.toAlignedRect();
}

void MiniMapRenderer::renderToImage(QImage& image, RenderFlags renderFlags) const
void MiniMapRenderer::renderToImage(QImage &image, RenderFlags renderFlags) const
{
if (!mMap)
return;
Expand Down

0 comments on commit cbf0cbd

Please sign in to comment.