diff --git a/docs/reference/json-map-format.rst b/docs/reference/json-map-format.rst index b4cd7faf86..88b51f9a2c 100644 --- a/docs/reference/json-map-format.rst +++ b/docs/reference/json-map-format.rst @@ -85,25 +85,27 @@ Layer chunks, array, "Array of :ref:`chunks ` (optional). ``tilelayer`` only." class, string, "The class of the layer (since 1.9, optional)" - compression, string, "``zlib``, ``gzip``, ``zstd`` (since Tiled 1.3) or empty (default). ``tilelayer`` only." + compression, string, "``zlib``, ``gzip``, ``zstd`` (since 1.3) or empty (default). ``tilelayer`` only." data, array or string, "Array of ``unsigned int`` (GIDs) or base64-encoded data. ``tilelayer`` only." draworder, string, "``topdown`` (default) or ``index``. ``objectgroup`` only." encoding, string, "``csv`` (default) or ``base64``. ``tilelayer`` only." height, int, "Row count. Same as map height for fixed-size maps. ``tilelayer`` only." id, int, "Incremental ID - unique across all layers" image, string, "Image used by this layer. ``imagelayer`` only." + imageheight, int, "Height of the image used by this layer. ``imagelayer`` only. (since 1.11.1)" + imagewidth, int, "Width of the image used by this layer. ``imagelayer`` only. (since 1.11.1)" layers, array, "Array of :ref:`layers `. ``group`` only." - locked, bool, "Whether layer is locked in the editor (default: false). (since Tiled 1.8.2)" + locked, bool, "Whether layer is locked in the editor (default: false). (since 1.8.2)" name, string, "Name assigned to this layer" objects, array, "Array of :ref:`objects `. ``objectgroup`` only." offsetx, double, "Horizontal layer offset in pixels (default: 0)" offsety, double, "Vertical layer offset in pixels (default: 0)" opacity, double, "Value between 0 and 1" - parallaxx, double, "Horizontal :ref:`parallax factor ` for this layer (default: 1). (since Tiled 1.5)" - parallaxy, double, "Vertical :ref:`parallax factor ` for this layer (default: 1). (since Tiled 1.5)" + parallaxx, double, "Horizontal :ref:`parallax factor ` for this layer (default: 1). (since 1.5)" + parallaxy, double, "Vertical :ref:`parallax factor ` for this layer (default: 1). (since 1.5)" properties, array, "Array of :ref:`Properties `" - repeatx, bool, "Whether the image drawn by this layer is repeated along the X axis. ``imagelayer`` only. (since Tiled 1.8)" - repeaty, bool, "Whether the image drawn by this layer is repeated along the Y axis. ``imagelayer`` only. (since Tiled 1.8)" + repeatx, bool, "Whether the image drawn by this layer is repeated along the X axis. ``imagelayer`` only. (since 1.8)" + repeaty, bool, "Whether the image drawn by this layer is repeated along the Y axis. ``imagelayer`` only. (since 1.8)" startx, int, "X coordinate where layer content starts (for infinite maps)" starty, int, "Y coordinate where layer content starts (for infinite maps)" tintcolor, string, "Hex-formatted :ref:`tint color ` (#RRGGBB or #AARRGGBB) that is multiplied with any graphics drawn by this layer or any child layers (optional)." @@ -736,6 +738,11 @@ A point on a polygon or a polyline, relative to the position of the object. Changelog --------- +Tiled 1.11.1 +~~~~~~~~~~~~ + +* Added ``imageheight`` and ``imagewidth`` properties to image layers. + Tiled 1.10 ~~~~~~~~~~ diff --git a/src/libtiled/maptovariantconverter.cpp b/src/libtiled/maptovariantconverter.cpp index 93e7fb882f..212a9b648a 100644 --- a/src/libtiled/maptovariantconverter.cpp +++ b/src/libtiled/maptovariantconverter.cpp @@ -693,6 +693,12 @@ QVariant MapToVariantConverter::toVariant(const ImageLayer &imageLayer) const const QString rel = toFileReference(imageLayer.imageSource(), mDir); imageLayerVariant[QStringLiteral("image")] = rel; + const QSize imageSize = imageLayer.image().size(); + if (!imageSize.isNull()) { + imageLayerVariant[QStringLiteral("imagewidth")] = imageSize.width(); + imageLayerVariant[QStringLiteral("imageheight")] = imageSize.height(); + } + const QColor transColor = imageLayer.transparentColor(); if (transColor.isValid()) imageLayerVariant[QStringLiteral("transparentcolor")] = transColor.name();