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

Improved reading 16-bit TGA images with colour #7965

Merged
merged 7 commits into from
Jun 28, 2024

Conversation

Yay295
Copy link
Contributor

@Yay295 Yay295 commented Apr 11, 2024

Looks like a typo in the mode name. The only other place "BGR;5" is used is in Unpack.c where it's an alias for "BGR;15".

The documentation I found says that it should actually be "BGRA;16" though, which isn't a mode we support.

@Yay295
Copy link
Contributor Author

Yay295 commented Apr 11, 2024

Actually, I missed it; "BGRA;15" is supported.

@Yay295 Yay295 changed the title Fix TGA rawmode BGR;15 Fix TGA rawmode BGRA;15 Apr 11, 2024
@radarhere
Copy link
Member

While the test suite now passes, if you actually run

with Image.open("Tests/images/p_16.tga") as im:
    im.save("out.png")

you get a transparent image.

Looking at 'Color Map Specification' in https://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf, it says

When working with VDA or VDA/D cards it is preferred that you select 16 bits (5 bits per primary with 1 bit to select interrupt control) and set the 16th bit to 0 so that the interrupt bit is disabled

I think setting the 16th bit to 0 actually means it is opaque, not transparent like Pillow is used to. I've created Yay295#20 to fix this. I've also updated the tests to compare with RGBA images to prevent this problem from slipping by again.

@hugovk hugovk merged commit c6d8c58 into python-pillow:main Jun 28, 2024
57 of 58 checks passed
@Yay295 Yay295 deleted the patch-3 branch June 28, 2024 14:03
@radarhere radarhere changed the title Fix TGA rawmode BGRA;15 Improved reading 16-bit TGA images with colour Jun 28, 2024
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.

3 participants