You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Documentation for PNMImage.flip implies that mirroring/transposing can be performed at the same time (with transpose after mirroring), and in fact all arguments are required at the same time:
However the actual implementation transposes if requested, then short-circuits mirroring. If mirroring in X and/or Y is required along with transposition, two calls to flip() are required.
Steps to Reproduce
PNMImage("somefile.png").flip(flip_x=True, flip_y=True, transpose=True) and note that only transposition is performed.
Environment
Operating system: Windows 11
System architecture: x64
Panda3D version: 1.10.14
Installation method: pip
Python version (if using Python): 3.11
Compiler (if using C++): N/A
The text was updated successfully, but these errors were encountered:
You're right. The problem I'm actually running into is that the ordering of the operations seems to be inverted in my reference data (produced from the Tiled map editor). It appears that Tiled transposes from top-left to bottom-right (so [0, 1, 2, 3] turns into [0, 2, 1, 3]) whereas Panda3D transposes bottom-left to top-right ([0, 1, 2, 3] -> [3, 1, 2, 0]).
So the right approach in my case is to reverse the flip_x/flip_y when also transposing. So this seems to work:
if flags.flipped_diagonally:
tmpimg.flip(flip_x=flags.flipped_vertically,
flip_y=flags.flipped_horizontally,
transpose=flags.flipped_diagonally)
else:
tmpimg.flip(flip_x=flags.flipped_horizontally,
flip_y=flags.flipped_vertically,
transpose=flags.flipped_diagonally)
Otherwise a less efficient solution would be to perform a separate flip() and only transpose, followed by a flip for mirroring X/Y only.
Description
Documentation for PNMImage.flip implies that mirroring/transposing can be performed at the same time (with transpose after mirroring), and in fact all arguments are required at the same time:
(https://docs.panda3d.org/1.10/python/reference/panda3d.core.PNMImage#panda3d.core.PNMImage.flip)
However the actual implementation transposes if requested, then short-circuits mirroring. If mirroring in X and/or Y is required along with transposition, two calls to flip() are required.
Steps to Reproduce
PNMImage("somefile.png").flip(flip_x=True, flip_y=True, transpose=True)
and note that only transposition is performed.Environment
The text was updated successfully, but these errors were encountered: