From 5043ba2fdf92d13ee45f7535cef15bd1fc46d112 Mon Sep 17 00:00:00 2001 From: Samuel Magnan-Levesque Date: Sun, 3 Feb 2019 18:19:57 -0500 Subject: [PATCH 1/5] Add support for .world files in tmxrasterizer --- src/tmxrasterizer/main.cpp | 4 +- src/tmxrasterizer/tmxrasterizer.cpp | 172 +++++++++++++++++++++------- src/tmxrasterizer/tmxrasterizer.h | 12 +- 3 files changed, 142 insertions(+), 46 deletions(-) diff --git a/src/tmxrasterizer/main.cpp b/src/tmxrasterizer/main.cpp index 8f09784b0e..e8c18a035c 100644 --- a/src/tmxrasterizer/main.cpp +++ b/src/tmxrasterizer/main.cpp @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) app.setApplicationVersion(QLatin1String("1.0")); QCommandLineParser parser; - parser.setApplicationDescription(QCoreApplication::translate("main", "Renders a Tiled map (TMX format) to an image.")); + parser.setApplicationDescription(QCoreApplication::translate("main", "Renders a Tiled map (TMX format) or a World map (WORLD format) to an image.")); parser.addHelpOption(); parser.addVersionOption(); parser.addOptions({ @@ -118,6 +118,6 @@ int main(int argc, char *argv[]) exit(1); } } - + return w.render(fileToOpen, fileToSave); } diff --git a/src/tmxrasterizer/tmxrasterizer.cpp b/src/tmxrasterizer/tmxrasterizer.cpp index e959bf425d..c1c084fea1 100644 --- a/src/tmxrasterizer/tmxrasterizer.cpp +++ b/src/tmxrasterizer/tmxrasterizer.cpp @@ -37,6 +37,7 @@ #include "orthogonalrenderer.h" #include "staggeredrenderer.h" #include "tilelayer.h" +#include "worldmanager.h" #include #include @@ -55,6 +56,48 @@ TmxRasterizer::TmxRasterizer(): { } +std::unique_ptr TmxRasterizer::createRenderer(Map& map) const +{ + switch (map.orientation()) { + case Map::Isometric: + return std::unique_ptr(new IsometricRenderer(&map)); + case Map::Staggered: + return std::unique_ptr(new StaggeredRenderer(&map)); + case Map::Hexagonal: + return std::unique_ptr(new HexagonalRenderer(&map)); + case Map::Orthogonal: + default: + return std::unique_ptr(new OrthogonalRenderer(&map)); + } +} +void TmxRasterizer::drawMapLayers(MapRenderer& renderer, + QPainter& painter, + Map& map, + QPoint mapOffset) const +{ + // Perform a similar rendering than found in exportasimagedialog.cpp + LayerIterator iterator(&map); + while (const Layer *layer = iterator.next()) { + if (!shouldDrawLayer(layer)) + continue; + + const auto offset = layer->totalOffset() + mapOffset; + painter.setOpacity(layer->effectiveOpacity()); + painter.translate(offset); + + const TileLayer *tileLayer = dynamic_cast(layer); + const ImageLayer *imageLayer = dynamic_cast(layer); + + if (tileLayer) { + renderer.drawTileLayer(&painter, tileLayer); + } else if (imageLayer) { + renderer.drawImageLayer(&painter, imageLayer); + } + + painter.translate(-offset); + } +} + bool TmxRasterizer::shouldDrawLayer(const Layer *layer) const { if (layer->isObjectGroup() || layer->isGroupLayer()) @@ -69,8 +112,17 @@ bool TmxRasterizer::shouldDrawLayer(const Layer *layer) const return !layer->isHidden(); } -int TmxRasterizer::render(const QString &mapFileName, +int TmxRasterizer::render(const QString &fileName, const QString &imageFileName) +{ + if(fileName.endsWith(".world")) + return renderWorld(fileName, imageFileName); + else + return renderMap(fileName, imageFileName); +} + +int TmxRasterizer::renderMap(const QString &mapFileName, + const QString &imageFileName) { MapReader reader; std::unique_ptr map { reader.readMap(mapFileName) }; @@ -81,24 +133,7 @@ int TmxRasterizer::render(const QString &mapFileName, return 1; } - std::unique_ptr renderer; - - switch (map->orientation()) { - case Map::Isometric: - renderer.reset(new IsometricRenderer(map.get())); - break; - case Map::Staggered: - renderer.reset(new StaggeredRenderer(map.get())); - break; - case Map::Hexagonal: - renderer.reset(new HexagonalRenderer(map.get())); - break; - case Map::Orthogonal: - default: - renderer.reset(new OrthogonalRenderer(map.get())); - break; - } - + std::unique_ptr renderer = createRenderer(*map.get()); QRect mapBoundingRect = renderer->mapBoundingRect(); QSize mapSize = mapBoundingRect.size(); QPoint mapOffset = mapBoundingRect.topLeft(); @@ -133,32 +168,15 @@ int TmxRasterizer::render(const QString &mapFileName, painter.translate(margins.left(), margins.top()); painter.translate(-mapOffset); - // Perform a similar rendering than found in exportasimagedialog.cpp - LayerIterator iterator(map.get()); - while (const Layer *layer = iterator.next()) { - if (!shouldDrawLayer(layer)) - continue; - - const auto offset = layer->totalOffset(); - - painter.setOpacity(layer->effectiveOpacity()); - painter.translate(offset); - - const TileLayer *tileLayer = dynamic_cast(layer); - const ImageLayer *imageLayer = dynamic_cast(layer); - - if (tileLayer) { - renderer->drawTileLayer(&painter, tileLayer); - } else if (imageLayer) { - renderer->drawImageLayer(&painter, imageLayer); - } - - painter.translate(-offset); - } - + drawMapLayers(*renderer.get(), painter, *map.get()); map.reset(); + return saveImage(imageFileName, image); +} - // Save image + +int TmxRasterizer::saveImage(const QString& imageFileName, + const QImage& image) const +{ QImageWriter imageWriter(imageFileName); if (!imageWriter.canWrite()) @@ -173,3 +191,71 @@ int TmxRasterizer::render(const QString &mapFileName, return 0; } + +int TmxRasterizer::renderWorld(const QString &worldFileName, + const QString &imageFileName) +{ + WorldManager &worldManager = WorldManager::instance(); + QString errorString; + const World *world = nullptr; + if (worldManager.loadWorld(worldFileName, &errorString)){ + auto const &worlds = worldManager.worlds(); + auto WorldIt = worlds.find(worldFileName); + if (WorldIt != worlds.end()) + world = WorldIt.value(); + } + if (world == nullptr) { + qWarning("Error loading the world file \"%s\":\n%s", + qUtf8Printable(worldFileName), + qUtf8Printable(errorString)); + return 1; + } + + auto const maps = world->allMaps(); + QRect worldBoundingRect; + bool boundsAreInit = false; + for (const World::MapEntry &mapEntry : maps) { + if (!boundsAreInit){ + boundsAreInit = true; + worldBoundingRect = mapEntry.rect; + continue; + } + if (worldBoundingRect.left() > mapEntry.rect.left()) + worldBoundingRect.setLeft(mapEntry.rect.left()); + if (worldBoundingRect.top() > mapEntry.rect.top()) + worldBoundingRect.setTop(mapEntry.rect.top()); + if (worldBoundingRect.right() < mapEntry.rect.right()) + worldBoundingRect.setRight(mapEntry.rect.right()); + if (worldBoundingRect.bottom() < mapEntry.rect.bottom()) + worldBoundingRect.setBottom(mapEntry.rect.bottom()); + } + + QSize mapSize = worldBoundingRect.size(); + QPoint mapOffset = worldBoundingRect.topLeft(); + + QImage image(mapSize * mScale, QImage::Format_ARGB32); + image.fill(Qt::transparent); + QPainter painter(&image); + + painter.setRenderHint(QPainter::Antialiasing, mUseAntiAliasing); + painter.setRenderHint(QPainter::SmoothPixmapTransform, mSmoothImages); + painter.setTransform(QTransform::fromScale(mScale, mScale)); + + painter.translate(-mapOffset); + + for (const World::MapEntry &mapEntry : maps) { + MapReader reader; + std::unique_ptr map { reader.readMap(mapEntry.fileName) }; + if (!map) { + qWarning("Error while reading \"%s\":\n%s", + qUtf8Printable(mapEntry.fileName), + qUtf8Printable(reader.errorString())); + return 1; + } + + std::unique_ptr renderer = createRenderer(*map.get()); + drawMapLayers(*renderer.get(), painter, *map.get(), mapEntry.rect.topLeft()); + } + + return saveImage(imageFileName, image); +} diff --git a/src/tmxrasterizer/tmxrasterizer.h b/src/tmxrasterizer/tmxrasterizer.h index b61866106f..a26cf72626 100644 --- a/src/tmxrasterizer/tmxrasterizer.h +++ b/src/tmxrasterizer/tmxrasterizer.h @@ -30,11 +30,16 @@ #include "layer.h" +#include "map.h" +#include "mapreader.h" #include #include using namespace Tiled; +class QImage; +class QPainter; + class TmxRasterizer { @@ -57,7 +62,7 @@ class TmxRasterizer void setLayersToHide(QStringList layersToHide) { mLayersToHide = layersToHide; } - int render(const QString &mapFileName, const QString &imageFileName); + int render(const QString &fileName, const QString &imageFileName); private: qreal mScale; @@ -68,5 +73,10 @@ class TmxRasterizer bool mIgnoreVisibility; QStringList mLayersToHide; + std::unique_ptr createRenderer(Map& map) const; + void drawMapLayers(MapRenderer& renderer, QPainter& painter, Map& map, QPoint mapOffset = QPoint(0,0)) const; + int renderMap(const QString &mapFileName, const QString &imageFileName); + int renderWorld(const QString &worldFileName, const QString &imageFileName); + int saveImage(const QString& imageFileName, const QImage& image) const; bool shouldDrawLayer(const Layer *layer) const; }; From 705a2586f2449f800d96f9da7ab9158cefc1ad45 Mon Sep 17 00:00:00 2001 From: Samuel Magnan-Levesque Date: Mon, 25 Mar 2019 20:27:22 -0400 Subject: [PATCH 2/5] Fix bug with map boundaries and minor changes --- src/libtiled/worldmanager.cpp | 8 +-- src/libtiled/worldmanager.h | 2 +- src/tmxrasterizer/main.cpp | 2 +- src/tmxrasterizer/tmxrasterizer.cpp | 82 ++++++++++++++++------------- 4 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/libtiled/worldmanager.cpp b/src/libtiled/worldmanager.cpp index f204bb7809..84d4cf4bfd 100644 --- a/src/libtiled/worldmanager.cpp +++ b/src/libtiled/worldmanager.cpp @@ -172,14 +172,14 @@ std::unique_ptr WorldManager::privateLoadWorld(const QString &fileName, /** * Loads the world with the given \a fileName. * - * \returns whether the world was loaded succesfully, optionally setting + * \returns the world if it was loaded succesfully, optionally setting * \a errorString when not. */ -bool WorldManager::loadWorld(const QString &fileName, QString *errorString) +World *WorldManager::loadWorld(const QString &fileName, QString *errorString) { auto world = privateLoadWorld(fileName, errorString); if (!world) - return false; + return nullptr; if (mWorlds.contains(fileName)) delete mWorlds.take(fileName); @@ -189,7 +189,7 @@ bool WorldManager::loadWorld(const QString &fileName, QString *errorString) mWorlds.insert(fileName, world.release()); emit worldsChanged(); - return true; + return mWorlds.value(fileName); } /** diff --git a/src/libtiled/worldmanager.h b/src/libtiled/worldmanager.h index 37fd16b7fe..09b381c29a 100644 --- a/src/libtiled/worldmanager.h +++ b/src/libtiled/worldmanager.h @@ -82,7 +82,7 @@ class TILEDSHARED_EXPORT WorldManager : public QObject static WorldManager &instance(); static void deleteInstance(); - bool loadWorld(const QString &fileName, QString *errorString = nullptr); + World *loadWorld(const QString &fileName, QString *errorString = nullptr); void unloadWorld(const QString &fileName); const QMap &worlds() const { return mWorlds; } diff --git a/src/tmxrasterizer/main.cpp b/src/tmxrasterizer/main.cpp index e8c18a035c..28e8533ee8 100644 --- a/src/tmxrasterizer/main.cpp +++ b/src/tmxrasterizer/main.cpp @@ -118,6 +118,6 @@ int main(int argc, char *argv[]) exit(1); } } - + return w.render(fileToOpen, fileToSave); } diff --git a/src/tmxrasterizer/tmxrasterizer.cpp b/src/tmxrasterizer/tmxrasterizer.cpp index c1c084fea1..4bcc45f60d 100644 --- a/src/tmxrasterizer/tmxrasterizer.cpp +++ b/src/tmxrasterizer/tmxrasterizer.cpp @@ -56,7 +56,7 @@ TmxRasterizer::TmxRasterizer(): { } -std::unique_ptr TmxRasterizer::createRenderer(Map& map) const +std::unique_ptr TmxRasterizer::createRenderer(Map &map) const { switch (map.orientation()) { case Map::Isometric: @@ -71,9 +71,9 @@ std::unique_ptr TmxRasterizer::createRenderer(Map& map) const } } void TmxRasterizer::drawMapLayers(MapRenderer& renderer, - QPainter& painter, - Map& map, - QPoint mapOffset) const + QPainter& painter, + Map& map, + QPoint mapOffset) const { // Perform a similar rendering than found in exportasimagedialog.cpp LayerIterator iterator(&map); @@ -115,7 +115,7 @@ bool TmxRasterizer::shouldDrawLayer(const Layer *layer) const int TmxRasterizer::render(const QString &fileName, const QString &imageFileName) { - if(fileName.endsWith(".world")) + if (fileName.endsWith(".world", Qt::CaseInsensitive)) return renderWorld(fileName, imageFileName); else return renderMap(fileName, imageFileName); @@ -133,7 +133,7 @@ int TmxRasterizer::renderMap(const QString &mapFileName, return 1; } - std::unique_ptr renderer = createRenderer(*map.get()); + std::unique_ptr renderer = createRenderer(*map); QRect mapBoundingRect = renderer->mapBoundingRect(); QSize mapSize = mapBoundingRect.size(); QPoint mapOffset = mapBoundingRect.topLeft(); @@ -168,7 +168,7 @@ int TmxRasterizer::renderMap(const QString &mapFileName, painter.translate(margins.left(), margins.top()); painter.translate(-mapOffset); - drawMapLayers(*renderer.get(), painter, *map.get()); + drawMapLayers(*renderer, painter, *map); map.reset(); return saveImage(imageFileName, image); } @@ -197,51 +197,57 @@ int TmxRasterizer::renderWorld(const QString &worldFileName, { WorldManager &worldManager = WorldManager::instance(); QString errorString; - const World *world = nullptr; - if (worldManager.loadWorld(worldFileName, &errorString)){ - auto const &worlds = worldManager.worlds(); - auto WorldIt = worlds.find(worldFileName); - if (WorldIt != worlds.end()) - world = WorldIt.value(); - } - if (world == nullptr) { + const World *world = worldManager.loadWorld(worldFileName, &errorString); + if (!world) { qWarning("Error loading the world file \"%s\":\n%s", qUtf8Printable(worldFileName), qUtf8Printable(errorString)); return 1; } - + auto const maps = world->allMaps(); + if (maps.isEmpty()) { + qWarning("Error: The world file to rasterize contains no maps : \"%s\"", + qUtf8Printable(worldFileName)); + return 1; + } QRect worldBoundingRect; - bool boundsAreInit = false; + MapReader reader; for (const World::MapEntry &mapEntry : maps) { - if (!boundsAreInit){ - boundsAreInit = true; - worldBoundingRect = mapEntry.rect; + std::unique_ptr map { reader.readMap(mapEntry.fileName) }; + if (!map) { + qWarning("Error while reading \"%s\":\n%s", + qUtf8Printable(mapEntry.fileName), + qUtf8Printable(reader.errorString())); continue; } - if (worldBoundingRect.left() > mapEntry.rect.left()) - worldBoundingRect.setLeft(mapEntry.rect.left()); - if (worldBoundingRect.top() > mapEntry.rect.top()) - worldBoundingRect.setTop(mapEntry.rect.top()); - if (worldBoundingRect.right() < mapEntry.rect.right()) - worldBoundingRect.setRight(mapEntry.rect.right()); - if (worldBoundingRect.bottom() < mapEntry.rect.bottom()) - worldBoundingRect.setBottom(mapEntry.rect.bottom()); - } - - QSize mapSize = worldBoundingRect.size(); - QPoint mapOffset = worldBoundingRect.topLeft(); - - QImage image(mapSize * mScale, QImage::Format_ARGB32); + std::unique_ptr renderer = createRenderer(*map); + QRect mapBoundingRect = renderer->mapBoundingRect(); + mapBoundingRect.translate(mapEntry.rect.topLeft()); + + worldBoundingRect = worldBoundingRect.united(mapBoundingRect); + } + qDebug() << worldBoundingRect; //NO_PROD + QSize worldSize = worldBoundingRect.size(); + qreal xScale, yScale; + if (mSize > 0) { + xScale = (qreal) mSize / worldSize.width(); + yScale = (qreal) mSize / worldSize.height(); + xScale = yScale = qMin(1.0, qMin(xScale, yScale)); + } else + xScale = yScale = mScale; + + worldSize.rwidth() *= xScale; + worldSize.rheight() *= yScale; + QImage image(worldSize, QImage::Format_ARGB32); image.fill(Qt::transparent); QPainter painter(&image); painter.setRenderHint(QPainter::Antialiasing, mUseAntiAliasing); painter.setRenderHint(QPainter::SmoothPixmapTransform, mSmoothImages); - painter.setTransform(QTransform::fromScale(mScale, mScale)); + painter.setTransform(QTransform::fromScale(xScale, yScale)); - painter.translate(-mapOffset); + painter.translate(-worldBoundingRect.topLeft()); for (const World::MapEntry &mapEntry : maps) { MapReader reader; @@ -253,8 +259,8 @@ int TmxRasterizer::renderWorld(const QString &worldFileName, return 1; } - std::unique_ptr renderer = createRenderer(*map.get()); - drawMapLayers(*renderer.get(), painter, *map.get(), mapEntry.rect.topLeft()); + std::unique_ptr renderer = createRenderer(*map); + drawMapLayers(*renderer, painter, *map, mapEntry.rect.topLeft()); } return saveImage(imageFileName, image); From 56b8aec358451dccecfae11e14aea3873289a885 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 26 Mar 2019 12:19:22 +0100 Subject: [PATCH 3/5] Small cleanups --- src/tmxrasterizer/tmxrasterizer.cpp | 21 +++++++++++---------- src/tmxrasterizer/tmxrasterizer.h | 6 +++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/tmxrasterizer/tmxrasterizer.cpp b/src/tmxrasterizer/tmxrasterizer.cpp index 4bcc45f60d..5d30d09ccd 100644 --- a/src/tmxrasterizer/tmxrasterizer.cpp +++ b/src/tmxrasterizer/tmxrasterizer.cpp @@ -140,12 +140,12 @@ int TmxRasterizer::renderMap(const QString &mapFileName, qreal xScale, yScale; if (mSize > 0) { - xScale = (qreal) mSize / mapSize.width(); - yScale = (qreal) mSize / mapSize.height(); + xScale = static_cast(mSize) / mapSize.width(); + yScale = static_cast(mSize) / mapSize.height(); xScale = yScale = qMin(1.0, qMin(xScale, yScale)); } else if (mTileSize > 0) { - xScale = (qreal) mTileSize / map->tileWidth(); - yScale = (qreal) mTileSize / map->tileHeight(); + xScale = static_cast(mTileSize) / map->tileWidth(); + yScale = static_cast(mTileSize) / map->tileHeight(); } else { xScale = yScale = mScale; } @@ -174,8 +174,8 @@ int TmxRasterizer::renderMap(const QString &mapFileName, } -int TmxRasterizer::saveImage(const QString& imageFileName, - const QImage& image) const +int TmxRasterizer::saveImage(const QString &imageFileName, + const QImage &image) const { QImageWriter imageWriter(imageFileName); @@ -227,15 +227,16 @@ int TmxRasterizer::renderWorld(const QString &worldFileName, worldBoundingRect = worldBoundingRect.united(mapBoundingRect); } - qDebug() << worldBoundingRect; //NO_PROD + QSize worldSize = worldBoundingRect.size(); qreal xScale, yScale; if (mSize > 0) { - xScale = (qreal) mSize / worldSize.width(); - yScale = (qreal) mSize / worldSize.height(); + xScale = static_cast(mSize) / worldSize.width(); + yScale = static_cast(mSize) / worldSize.height(); xScale = yScale = qMin(1.0, qMin(xScale, yScale)); - } else + } else { xScale = yScale = mScale; + } worldSize.rwidth() *= xScale; worldSize.rheight() *= yScale; diff --git a/src/tmxrasterizer/tmxrasterizer.h b/src/tmxrasterizer/tmxrasterizer.h index a26cf72626..b4d3c9432b 100644 --- a/src/tmxrasterizer/tmxrasterizer.h +++ b/src/tmxrasterizer/tmxrasterizer.h @@ -51,7 +51,7 @@ class TmxRasterizer int size() const { return mSize; } bool useAntiAliasing() const { return mUseAntiAliasing; } bool smoothImages() const { return mSmoothImages; } - bool IgnoreVisibility() const { return mIgnoreVisibility; } + bool ignoreVisibility() const { return mIgnoreVisibility; } void setScale(qreal scale) { mScale = scale; } void setTileSize(int tileSize) { mTileSize = tileSize; } @@ -74,9 +74,9 @@ class TmxRasterizer QStringList mLayersToHide; std::unique_ptr createRenderer(Map& map) const; - void drawMapLayers(MapRenderer& renderer, QPainter& painter, Map& map, QPoint mapOffset = QPoint(0,0)) const; + void drawMapLayers(MapRenderer &renderer, QPainter &painter, Map &map, QPoint mapOffset = QPoint(0, 0)) const; int renderMap(const QString &mapFileName, const QString &imageFileName); int renderWorld(const QString &worldFileName, const QString &imageFileName); - int saveImage(const QString& imageFileName, const QImage& image) const; + int saveImage(const QString &imageFileName, const QImage &image) const; bool shouldDrawLayer(const Layer *layer) const; }; From bd0e141c5fcf7407fe4b193c404c5ca5aea46b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 26 Mar 2019 12:21:00 +0100 Subject: [PATCH 4/5] More reference symbol positioning tweaks --- src/tmxrasterizer/tmxrasterizer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tmxrasterizer/tmxrasterizer.cpp b/src/tmxrasterizer/tmxrasterizer.cpp index 5d30d09ccd..26cccb892b 100644 --- a/src/tmxrasterizer/tmxrasterizer.cpp +++ b/src/tmxrasterizer/tmxrasterizer.cpp @@ -70,9 +70,9 @@ std::unique_ptr TmxRasterizer::createRenderer(Map &map) const return std::unique_ptr(new OrthogonalRenderer(&map)); } } -void TmxRasterizer::drawMapLayers(MapRenderer& renderer, - QPainter& painter, - Map& map, +void TmxRasterizer::drawMapLayers(MapRenderer &renderer, + QPainter &painter, + Map &map, QPoint mapOffset) const { // Perform a similar rendering than found in exportasimagedialog.cpp From 05d26f2248beb96f8871648a5982fdf02cbc9f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 26 Mar 2019 12:23:55 +0100 Subject: [PATCH 5/5] Make createRenderer static --- src/tmxrasterizer/tmxrasterizer.cpp | 23 ++++++++++++----------- src/tmxrasterizer/tmxrasterizer.h | 1 - 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/tmxrasterizer/tmxrasterizer.cpp b/src/tmxrasterizer/tmxrasterizer.cpp index 26cccb892b..f15ca81074 100644 --- a/src/tmxrasterizer/tmxrasterizer.cpp +++ b/src/tmxrasterizer/tmxrasterizer.cpp @@ -46,17 +46,7 @@ using namespace Tiled; -TmxRasterizer::TmxRasterizer(): - mScale(1.0), - mTileSize(0), - mSize(0), - mUseAntiAliasing(false), - mSmoothImages(true), - mIgnoreVisibility(false) -{ -} - -std::unique_ptr TmxRasterizer::createRenderer(Map &map) const +static std::unique_ptr createRenderer(Map &map) { switch (map.orientation()) { case Map::Isometric: @@ -70,6 +60,17 @@ std::unique_ptr TmxRasterizer::createRenderer(Map &map) const return std::unique_ptr(new OrthogonalRenderer(&map)); } } + +TmxRasterizer::TmxRasterizer(): + mScale(1.0), + mTileSize(0), + mSize(0), + mUseAntiAliasing(false), + mSmoothImages(true), + mIgnoreVisibility(false) +{ +} + void TmxRasterizer::drawMapLayers(MapRenderer &renderer, QPainter &painter, Map &map, diff --git a/src/tmxrasterizer/tmxrasterizer.h b/src/tmxrasterizer/tmxrasterizer.h index b4d3c9432b..a91ca966f9 100644 --- a/src/tmxrasterizer/tmxrasterizer.h +++ b/src/tmxrasterizer/tmxrasterizer.h @@ -73,7 +73,6 @@ class TmxRasterizer bool mIgnoreVisibility; QStringList mLayersToHide; - std::unique_ptr createRenderer(Map& map) const; void drawMapLayers(MapRenderer &renderer, QPainter &painter, Map &map, QPoint mapOffset = QPoint(0, 0)) const; int renderMap(const QString &mapFileName, const QString &imageFileName); int renderWorld(const QString &worldFileName, const QString &imageFileName);