Dawn reset
This commit is contained in:
@ -9,7 +9,9 @@ import argparse
|
||||
import os
|
||||
|
||||
# Args
|
||||
parser = argparse.ArgumentParser(description='Converts image textures to internal game data format.')
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Converts image textures to internal game data format.'
|
||||
)
|
||||
parser.add_argument('-i', '--input');
|
||||
parser.add_argument('-o', '--output');
|
||||
parser.add_argument('-s', '--scale');
|
||||
@ -33,7 +35,11 @@ if not os.path.exists(args.input):
|
||||
img = Image.open(args.input)
|
||||
|
||||
# Normalize the image
|
||||
hasAlpha = img.mode == 'RGBA' or img.mode == 'LA'
|
||||
hasAlpha = (
|
||||
img.mode == 'RGBA' or img.mode == 'LA' or (
|
||||
img.mode == 'P' and 'transparency' in img.info
|
||||
)
|
||||
)
|
||||
|
||||
# Convert the image to RGB or RGBA mode based on alpha channel
|
||||
if hasAlpha:
|
||||
@ -67,12 +73,12 @@ if args.scale not in (None, ""):
|
||||
|
||||
|
||||
# Filter
|
||||
if args.filter_min.lower() == 'NEAREST':
|
||||
if args.filter_min.lower() == 'nearest':
|
||||
filterMin = 0
|
||||
else:
|
||||
filterMin = 1
|
||||
|
||||
if args.filter_mag.lower() == 'NEAREST':
|
||||
if args.filter_mag.lower() == 'nearest':
|
||||
filterMag = 0
|
||||
else:
|
||||
filterMag = 1
|
||||
@ -108,6 +114,7 @@ os.makedirs(os.path.dirname(args.output), exist_ok=True)
|
||||
|
||||
# Write the image metadata and pixel data to the output file
|
||||
with open(args.output, 'wb') as f:
|
||||
header = f"DT_2.00|{img.width}|{img.height}|{4 if hasAlpha else 3}|{wrapX}|{wrapY}|{filterMin}|{filterMag}|"
|
||||
header = f"DT_2.00|{img.width}|{img.height}|{4 if hasAlpha else 3}|"
|
||||
header += f"{wrapX}|{wrapY}|{filterMin}|{filterMag}|"
|
||||
f.write(header.encode())
|
||||
f.write(buffer)
|
Reference in New Issue
Block a user