pytmx icon indicating copy to clipboard operation
pytmx copied to clipboard

Added alphaonly imageloader parameter.

Open spgilmore opened this issue 1 year ago • 2 comments

The new alphaonly parameter circumvents the smart part of the smart_convert() method when pygame misbehaves with non-transparent tiles. This should be a non-breaking change.

Here is the problem I have: There are certain tiles which I created without transparency will be determined by pygame's .mask() method to have no transparency. The smart_convert() method then correctly calls .convert() on them. But then pygame draws these tiles without drawing the black pixels. As far as I can tell, the problem is in PyGame. It's possible that it's something weird about my tilesheet imaages, but it only does it with certain tiles. This is not a bug in pytmx. I've had this problem for YEARS with pygame. Whether it's me or them, the solution to my problem is to use convert_alpha(). This new parameter gives me the control to force pytmx to do that. Without this change, I had to create a custom image loader to solve this problem.

spgilmore avatar Dec 15 '23 22:12 spgilmore

Thank you for reviewing this. I'm happy to make any changes you suggest to get this merged. I'd really like to have these changes available in PIP.

spgilmore avatar Jan 16 '24 04:01 spgilmore

tbh, im personally hesitant to add more parameters to the loader function, but i will entertain the idea. because to me, if there is a bug where some images have transparent tiles, but that is not determined properly, then the bug should be fixed, rather than adding some workaround for the problem. workarounds for bugs become "features" and a maintenance burden. actually fixing the transparent pixel bug would be much more appropriate than just covering it up and adding more "features".

bitcraft avatar Jan 17 '24 14:01 bitcraft