Skip to content

Commit 1b30650

Browse files
authored
Remove unnecessary code in Texture2DConverter (#320)
* fix(Texture2DConverter): unnecessary code
1 parent 6945166 commit 1b30650

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

UnityPy/export/Texture2DConverter.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ def pad_image(img: Image.Image, pad_width: int, pad_height: int) -> Image.Image:
5555
if pad_width == ori_width and pad_height == ori_height:
5656
return img
5757

58-
pad_img = Image.new(img.mode, (pad_width, pad_height))
59-
pad_img.paste(img)
60-
6158
# Paste the original image at the top-left corner
59+
pad_img = Image.new(img.mode, (pad_width, pad_height))
6260
pad_img.paste(img, (0, 0))
6361

6462
# Fill the right border: duplicate the last column
@@ -259,15 +257,6 @@ def image_to_texture2d(
259257
return enc_img, tex_format
260258

261259

262-
def assert_rgba(img: Image.Image, target_texture_format: TextureFormat) -> Image.Image:
263-
if img.mode == "RGB":
264-
img = img.convert("RGBA")
265-
assert img.mode == "RGBA", (
266-
f"{target_texture_format} compression only supports RGB & RGBA images"
267-
) # noqa: E501
268-
return img
269-
270-
271260
def get_image_from_texture2d(
272261
texture_2d: Texture2D,
273262
flip: bool = True,
@@ -341,8 +330,7 @@ def parse_image_data(
341330
if not selection:
342331
raise NotImplementedError(f"Not implemented texture format: {texture_format}")
343332

344-
if not isinstance(image_data, bytes):
345-
image_data = bytes(image_data)
333+
image_data = bytes(image_data)
346334

347335
if "Crunched" in texture_format.name:
348336
if (

0 commit comments

Comments
 (0)