mirror of
https://github.com/Kaisaan/lostkefin.git
synced 2025-06-18 08:35:38 -04:00
Update graphics.py
This commit is contained in:
parent
f3ca4855e6
commit
c941ed5b8f
19
graphics.py
19
graphics.py
@ -1,6 +1,7 @@
|
||||
from PIL import Image
|
||||
import sys
|
||||
import numpy as np
|
||||
from struct import pack
|
||||
|
||||
def intlit(bytes):
|
||||
return int.from_bytes(bytes, "little")
|
||||
@ -41,7 +42,6 @@ if (clutSize == 256):
|
||||
bpp = 8
|
||||
elif (clutSize == 16):
|
||||
bpp = 4
|
||||
quit("4 BPP Image not supported yet")
|
||||
else:
|
||||
quit("other BPP Image not supported yet")
|
||||
|
||||
@ -115,9 +115,9 @@ if clutSize == 256:
|
||||
colours = graphic.read(sectionSize)
|
||||
clut = clut + colours
|
||||
|
||||
#clut = graphic.read(clutSize * palSize)
|
||||
|
||||
#print(clut)
|
||||
elif bpp == 4:
|
||||
clut = graphic.read(clutSize * palSize)
|
||||
print(clut)
|
||||
|
||||
#PIL.ImagePalette.ImagePalette("RGBA", clut)
|
||||
|
||||
@ -166,11 +166,20 @@ for x in range(sprCount):
|
||||
#print(sprDataSize)
|
||||
|
||||
graphic.seek(pxlOffset + sprOffset)
|
||||
sprData = graphic.read(sprDataSize)
|
||||
|
||||
#print(sprData)
|
||||
|
||||
#if (bpp == 4):
|
||||
|
||||
if (bpp == 4):
|
||||
sprData4 = graphic.read(sprDataSize)
|
||||
sprData = b""
|
||||
for byte in sprData4:
|
||||
# These might be backwards
|
||||
sprData += pack("bb", byte & 0xF, byte >> 4)
|
||||
else:
|
||||
sprData = graphic.read(sprDataSize)
|
||||
|
||||
sprite = Image.frombytes("P", sprSize, bytes(sprData))
|
||||
sprite.putpalette(clut, rawmode="RGBA")
|
||||
sprite.save(f"{filename}_{x}.png")
|
||||
|
Loading…
Reference in New Issue
Block a user