From fc6afb54a25fb99c82092438a893767a0920a3ab Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Thu, 29 May 2025 12:19:02 +0800 Subject: [PATCH 1/2] fix(Texture2DConverter): unnecessary code --- UnityPy/export/Texture2DConverter.py | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/UnityPy/export/Texture2DConverter.py b/UnityPy/export/Texture2DConverter.py index e6aa7a46..ac9b4136 100644 --- a/UnityPy/export/Texture2DConverter.py +++ b/UnityPy/export/Texture2DConverter.py @@ -1,4 +1,4 @@ -from __future__ import annotations +from __future__ import annotations import struct from io import BytesIO @@ -55,10 +55,8 @@ def pad_image(img: Image.Image, pad_width: int, pad_height: int) -> Image.Image: if pad_width == ori_width and pad_height == ori_height: return img - pad_img = Image.new(img.mode, (pad_width, pad_height)) - pad_img.paste(img) - # Paste the original image at the top-left corner + pad_img = Image.new(img.mode, (pad_width, pad_height)) pad_img.paste(img, (0, 0)) # Fill the right border: duplicate the last column @@ -259,15 +257,6 @@ def image_to_texture2d( return enc_img, tex_format -def assert_rgba(img: Image.Image, target_texture_format: TextureFormat) -> Image.Image: - if img.mode == "RGB": - img = img.convert("RGBA") - assert img.mode == "RGBA", ( - f"{target_texture_format} compression only supports RGB & RGBA images" - ) # noqa: E501 - return img - - def get_image_from_texture2d( texture_2d: Texture2D, flip: bool = True, @@ -341,8 +330,7 @@ def parse_image_data( if not selection: raise NotImplementedError(f"Not implemented texture format: {texture_format}") - if not isinstance(image_data, bytes): - image_data = bytes(image_data) + image_data = bytes(image_data) if "Crunched" in texture_format.name: if ( From 8c704ee1613ef9502cdfb4f3013c1dae5e360875 Mon Sep 17 00:00:00 2001 From: Rudolf Kolbe Date: Sat, 31 May 2025 21:00:35 +0200 Subject: [PATCH 2/2] chore(Texture2DConverter): ruff format Texture2DConverter --- UnityPy/export/Texture2DConverter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/export/Texture2DConverter.py b/UnityPy/export/Texture2DConverter.py index ac9b4136..6b04bb36 100644 --- a/UnityPy/export/Texture2DConverter.py +++ b/UnityPy/export/Texture2DConverter.py @@ -1,4 +1,4 @@ -from __future__ import annotations +from __future__ import annotations import struct from io import BytesIO