Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TMX format: Support embedded images on the tileset #3841

Merged
merged 7 commits into from
Jan 30, 2024

Conversation

bjorn
Copy link
Member

@bjorn bjorn commented Nov 6, 2023

Previously, embedded images were only supported per-tile. Due to the recent change to use sub-rects rather than physically cutting up the tileset, when you called Tileset.loadFromImage(image), the entire tileset image would get duplicated for each tile.

Now the image is embedded once at the tileset level instead.

Also, the Tileset.margin and Tileset.tileSpacing properties are now writable in the scripting API.

Addresses part of #3630.

bjorn added 2 commits November 6, 2023 11:59
Previously, embedded images were only supported per-tile. Due to the
recent change to use sub-rects rather than physically cutting up the
tileset, when you called Tileset.loadFromImage(image), the entire
tileset image would get duplicated for each tile.

Now the image is embedded once at the tileset level instead.

Also, the Tileset.margin and Tileset.tileSpacing properties are now
writable in the scripting API.

Addresses part of mapeditor#3630.
Unified the writing of "image" elements between tilesets, tiles and
image layers, and made sure that embedding of images is supported
everywhere.

It is still only possible to create an embedded image through the
scripting API, by setting an image without specifying its source.
@eishiya
Copy link
Contributor

eishiya commented Nov 13, 2023

The documentation for the XML and JSON formats should probably be amended to mention the possibility of the image source being a base-64 data URL. Currently, this doesn't seem to even be described well for image collection tiles, where this has been a feature for a while. The XML documentation page mentions that an image can have format and data, but links to the description of <data>, which deals solely with tile layer data and not with image data. Is this format/data thing even accurate?

@bjorn
Copy link
Member Author

bjorn commented Nov 13, 2023

The XML documentation page mentions that an image can have format and data, but links to the description of <data>, which deals solely with tile layer data and not with image data. Is this format/data thing even accurate?

Yes, this is accurate. Embedded images are not stored as a base-64 data URL, but re-use the "data" element also used by tile layer data. The documentation for the "data" element should be updated to mention this, though.

The JSON format still does not support embedded images. I will look into supporting it and then of course will need to adjust the documentation.

@eishiya
Copy link
Contributor

eishiya commented Nov 13, 2023

Gotcha. It'd be good to mention the use for images in the section, even if it's just to say that the data may be binary image data in the case of in elements. Presumably, CSV encoding isn't supported for image data.

bjorn added 4 commits January 30, 2024 20:36
* Mention that maps and tilesets with embedded image data can be created
  using the JavaScript API.

* Note that the <data> element can be used for both tile layer data as
  well as image data.
@bjorn bjorn force-pushed the embedded-tileset-image branch from 272a39d to 85c36fd Compare January 30, 2024 19:47
@bjorn bjorn merged commit 85c36fd into mapeditor:master Jan 30, 2024
12 of 13 checks passed
@bjorn bjorn deleted the embedded-tileset-image branch January 30, 2024 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants