libtmx  0.4.0
an C++11 library for reading TMX files
How to render image objects with libtmx?

An image object is an image that is part of an object layer in Tiled. This image is associated with a tile in a tileset. It is represented by a tmx::TileObject in the library. This tutorial provides some hints on how to render this type of object in a neutral way, You should read How to render tiles with libtmx? before reading this tutorial as the first step is the same.

Visit the layer

We visit the object layer.

virtual void visitObjectLayer(const tmx::Map& map, const tmx::ObjectLayer &layer) override {
if (!layer.isVisible()) {
for (auto obj : layer) {
if (!obj->isTile()) {
auto tile = static_cast<const tmx::TileObject *>(obj);
unsigned x = tile->getX();
unsigned y = tile->getY();
unsigned gid = tile->getGID();
drawObjectGID(map, x, y, gid);

First, it's not necessary to render the layer if it's not visible. This visibility property can be set in Tiled. Then if we find an image object in the objects of this layer, then we get its position and its gid and draw it.

Draw the image

The procedure for drawing the image is quite the same as the one in How to render tiles with libtmx?, except the call to drawImage. Indeed, the origin of the image object is not at the top left of the image but at the bottom left. So the call to drawImage is something like:

drawImage(x, y - height, texture, rect); // depends on the toolkit
See also
How to render tiles with libtmx?