Skip to content

Commit

Permalink
Improved psx.writeTIM
Browse files Browse the repository at this point in the history
  • Loading branch information
Illidanz committed Apr 15, 2022
1 parent 8fc76d5 commit 49676f0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions hacktools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ def readRGB5A1(color):
return (r, g, b, a)


def getPaletteIndex(palette, color, fixtransp=False, starti=0, palsize=-1, checkalpha=False, zerotransp=True, backwards=False):
def getPaletteIndex(palette, color, fixtransp=False, starti=0, palsize=-1, checkalpha=False, zerotransp=True, backwards=False, logcolor=False):
if zerotransp and color[3] == 0:
return 0
if palsize == -1:
Expand Down Expand Up @@ -1154,7 +1154,8 @@ def getPaletteIndex(palette, color, fixtransp=False, starti=0, palsize=-1, check
if distance < mindist:
mindist = distance
disti = i - starti
logDebug("Color", color, "not found, closest color:", palette[disti])
if logcolor:
logDebug("Color", color, "not found, closest color:", palette[disti])
return disti


Expand Down
9 changes: 6 additions & 3 deletions hacktools/psx.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,12 @@ def writeTIM(f, tim, infile, transp=False, forcepal=-1):
common.logError("writeTIM bpp", tim.bpp, "not supported")
return
clut = forcepal if forcepal != -1 else getUniqueCLUT(tim, transp)
img = Image.open(infile)
img = img.convert("RGBA")
pixels = img.load()
if isinstance(infile, str):
img = Image.open(infile)
img = img.convert("RGBA")
pixels = img.load()
else:
pixels = infile
f.seek(tim.dataoff)
for i in range(tim.height):
for j in range(tim.width):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="hacktools",
version="0.24.0",
version="0.24.1",
author="Illidan",
description="A set of utilities and tools for rom hacking and translations.",
long_description=long_description,
Expand Down

0 comments on commit 49676f0

Please sign in to comment.