mirror of
https://github.com/mon/ifstools.git
synced 2026-08-23 02:44:18 -05:00
Add support to encode argb4444 textures
Some checks failed
CI / linux (map[runner:ubuntu-22.04 target:aarch64]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:armv7]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:ppc64le]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:s390x]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:x86]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:x86_64]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:aarch64]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:armv7]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:x86]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:x86_64]) (push) Has been cancelled
CI / windows (map[python_arch:x64 runner:windows-latest target:x64]) (push) Has been cancelled
CI / windows (map[python_arch:x86 runner:windows-latest target:x86]) (push) Has been cancelled
CI / macos (map[runner:macos-15-intel target:x86_64]) (push) Has been cancelled
CI / macos (map[runner:macos-latest target:aarch64]) (push) Has been cancelled
CI / sdist (push) Has been cancelled
CI / Standalone .exe (Windows x86_64) (push) Has been cancelled
CI / Release (push) Has been cancelled
Some checks failed
CI / linux (map[runner:ubuntu-22.04 target:aarch64]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:armv7]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:ppc64le]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:s390x]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:x86]) (push) Has been cancelled
CI / linux (map[runner:ubuntu-22.04 target:x86_64]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:aarch64]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:armv7]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:x86]) (push) Has been cancelled
CI / musllinux (map[runner:ubuntu-22.04 target:x86_64]) (push) Has been cancelled
CI / windows (map[python_arch:x64 runner:windows-latest target:x64]) (push) Has been cancelled
CI / windows (map[python_arch:x86 runner:windows-latest target:x86]) (push) Has been cancelled
CI / macos (map[runner:macos-15-intel target:x86_64]) (push) Has been cancelled
CI / macos (map[runner:macos-latest target:aarch64]) (push) Has been cancelled
CI / sdist (push) Has been cancelled
CI / Standalone .exe (Windows x86_64) (push) Has been cancelled
CI / Release (push) Has been cancelled
Honestly dunno why I didn't do this literally years ago, it's just reversing the existing logic...
This commit is contained in:
@@ -43,6 +43,13 @@ def decode_argb4444(ifs_img, data):
|
||||
r, g, b, a = im.split()
|
||||
return Image.merge('RGBA', (b, g, r, a))
|
||||
|
||||
def encode_argb4444(ifs_img, image):
|
||||
# there's no BGRA;4B
|
||||
r, g, b, a = image.split()
|
||||
image = Image.merge('RGBA', (b, g, r, a))
|
||||
|
||||
return image.tobytes('raw', 'RGBA;4B')
|
||||
|
||||
def decode_dxt(ifs_img, data, version):
|
||||
rgba = _native.decode_dxt(data, ifs_img.img_size[0], ifs_img.img_size[1], version)
|
||||
return Image.frombytes('RGBA', ifs_img.img_size, rgba)
|
||||
@@ -59,7 +66,7 @@ def encode_dxt5(ifs_img, image):
|
||||
|
||||
image_formats = {
|
||||
'argb8888rev' : {'decoder': decode_argb8888rev, 'encoder': encode_argb8888rev},
|
||||
'argb4444' : {'decoder': decode_argb4444, 'encoder': None},
|
||||
'argb4444' : {'decoder': decode_argb4444, 'encoder': encode_argb4444},
|
||||
'dxt1' : {'decoder': decode_dxt1, 'encoder': None},
|
||||
'dxt5' : {'decoder': decode_dxt5, 'encoder': encode_dxt5 if _native else None},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user