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

TextureDef.to_Image() #18

Open
jmickle66666666 opened this issue Mar 22, 2017 · 0 comments
Open

TextureDef.to_Image() #18

jmickle66666666 opened this issue Mar 22, 2017 · 0 comments

Comments

@jmickle66666666
Copy link
Contributor

jmickle66666666 commented Mar 22, 2017

Give the user the option to export a texture, built from patches, as an Image(). Currently omgifol users have to manually traverse the data and build patches themselves, but this should be an in-built feature of omgifol.

My current implementation (including transparency fix in issue #17) is as follows:

wad = omg.WAD(path)
tex = omg.txdef.Textures(wad.txdefs)

# build the textures out of the patches
for texturedef in tex:
  new_img = Image.new("RGBA", (tex[texturedef].width, tex[texturedef].height))
  for p in tex[texturedef].patches:
    pimg = wad.patches[p.name.upper()].to_Image()
    pimg = pimg.convert("RGBA")
    # try and fix transparency issues
    pixdata = pimg.load()

    width, height = pimg.size
    for y in xrange(height):
      for x in xrange(width):
        if pixdata[x, y] == (255, 0, 255, 255):
          pixdata[x, y] = (255, 255, 255, 0)

    new_img.paste(pimg, (p.x, p.y), pimg)

but this should be as simple as follows:

wad = omg.WAD(path)
tex = omg.txdef.Textures(wad.txdefs)

# get the textures
for texturedef in tex:
  new_img = tex[texturedef].to_Image()
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

No branches or pull requests

1 participant