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

Update tex2ngl.py to work for more types of images #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

miracade
Copy link

@miracade miracade commented Aug 3, 2022

I recently found that tex2ngl currently doesn't work for images which aren't in RGB or RGBA format (for example, PNGs in indexed mode). PIL's Image.convert() method is an easy fix

I recently found that tex2ngl currently doesn't work for images which aren't in RGB or RGBA format (for example, PNGs in indexed mode). PIL's `Image.convert()` method is an easy fix
@@ -13,7 +13,7 @@ def color2ngl(r, g, b, _=0):

def tex2ngl(src):
"""Converts src to C header containing nGL TEXTURE. Returns tuple(code, object name, tuple(w, h))."""
img = Image.open(src)
img = Image.open(src).convert("RGBA")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transparency isn't supported (yet), so just RGB might make more sense

@miracade
Copy link
Author

miracade commented Aug 7, 2022

Make sense to me. From my testing, converting from a format with an alpha channel to RGB doesn't raise any warnings or anything so this shouldn't break anything

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.

2 participants