[SOLVED] Image tile preview bug (modified draw process)

Due to image/link limitation, you can see this post with image and link here : https://docs.google.com/document/d/1LTsfjtEWKtRjuPtAdsvtc0yo0XVcgxKleoceZ7k2_rQ/edit?usp=sharing

Actually, Tiled draw tile imge on left bottom of cell like this and for my game I have to draw the left top of tile on center of cell. And after, each tile image have offset shift.

So, on Tiled source code I have modified mapreader, maprwrite and tile to add image offset
Exemple of .tsx file (I have added imageoffset property) :

<tile id="0">
    <image width="104" height="142" source="tiles/0.png"/>
    <imageoffset x="0" y="0"/>
</tile>

And in CellRenderer::render function of maprenderer I have modified the tile renderer.
(see google doc)

The tile is positionned correctly with and without offset, but I have little problem with image preview on map view, the tile image is not correctly displayed, I have to zoom-in/zoom-out the see the result :

The code of my modification is available on my fork : https://github.com/ElonDev/tiled/commit/9b5590795d66ac525b9c9b39b8d390e3b0fa00e6

The repaint artifacts are to be expected because Tiled only repaints the parts that are changing. If you draw your tiles at an offset then this means you would need to teach it how to take this offset in account while determining which parts to repaint.

Since explaining how to do that as well as implementing this could get a little involved, you could alternatively set the MapView to always repaint in its entirety whenever anything changes. You can do this by setting the viewport update mode to QGraphicsView::FullViewportUpdate (for example in the MapView constructor). The full viewport update mode is also used when you enable OpenGL-accelerated rendering in the preferences.

Btw, I see you selected “Left Up” as your tile rendering order so I just wanted to note that the tile rendering order currently only works for Orthogonal maps. It still needs to be implemented for isometric, staggered and hexagonal maps.

Good luck!

This work like a charm, thanks you very much :wink:
And thanks too about information of Left Up mode.

Hmm, @Elon, where did your Tiled fork go? Somebody just requested your feature:

https://github.com/bjorn/tiled/issues/871

You can find the commit in any fork: https://github.com/bjorn/tiled/commit/9b5590795d66ac525b9c9b39b8d390e3b0fa00e6.

Hi, I have move repo in organization team.
I have recreate old fork with only needed change.

Commits : https://github.com/ElonDev/tiled/commits/master