Skip to content

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

Open
miracade wants to merge 1 commit intoVogtinator:masterfrom
miracade:patch-1
Open

Update tex2ngl.py to work for more types of images#3
miracade wants to merge 1 commit intoVogtinator:masterfrom
miracade:patch-1

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
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

Comments