Skip to content

TextureDef.to_Image() #18

Description

@jmickle66666666

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions