self.high_quality_mode = highqualitymode\r
self.high_cmp_ratio_mode = highcmpratiomode\r
\r
+ self.img = cv2.imread(img_dir, cv2.IMREAD_UNCHANGED) #返回长宽分辨率元素组\r
+ if self.img.shape[2] > 3:\r
+ self.file_alpha = True\r
+ else:\r
+ self.file_alpha = False\r
+ \r
im = Image.open(img_dir)\r
if color_fmt != ' ':\r
self.color_fmt = color_fmt\r
self.color_fmt = 'ARGB8888'\r
elif im.mode == 'RGB':\r
self.color_fmt = 'RGB888'\r
+ elif self.file_alpha == True:\r
+ self.color_fmt = 'ARGB8888'\r
+ else:\r
+ self.color_fmt = 'RGB888'\r
\r
if (self.cmp_mode != "NONE") and (self.cmp_mode != "HFBC") and \\r
(self.cmp_mode != "HFBC_ABYPASS") :\r
(self.color_fmt != "ARGB8888"):\r
print("error: unsupported image format:", self.color_fmt)\r
exit(1)\r
- self.img = cv2.imread(img_dir, cv2.IMREAD_UNCHANGED) #返回长宽分辨率元素组\r
self.height = self.img.shape[0]\r
self.width = self.img.shape[1]\r
self.tile_width = tile #4\r
self.stride_pixel = (self.width +\r
self.align - 1) // self.align * self.align\r
self.version = ver\r
- if self.img.shape[2] > 3:\r
- self.file_alpha = True\r
- else:\r
- self.file_alpha = False\r
\r
\r
def convert(self):\r
from converter_C import Converter_C\r
from converterdcmp import Converterdcmp\r
import searchdir\r
+import cv2\r
+import time\r
+\r
+# 记录脚本开始时间\r
+start_time = time.time()\r
+\r
version = '0'\r
def make_sure_dir_exit(filename):\r
if not os.path.exists(os.path.dirname(filename)):\r
g_file_config = {}\r
g_file_output = {}\r
g_file_output2 = {}\r
+dir_id = 1\r
+g_image_resource = []\r
\r
def parse_child(root, dir_name):\r
+ global dir_id\r
for child in root:\r
parse_child(child, os.path.join(dir_name, child.get('name')))\r
compress = root.get('compress')\r
auto_cmp_mode = root.get('autocmpmode')\r
high_quality_mode = root.get('highqualitymode')\r
high_cmp_ratio_mode = root.get('highcmpratiomode')\r
+ dir_id_str = root.get('dirid')\r
+ if dir_id_str != None:\r
+ if "0x" in dir_id_str: \r
+ dir_id = int(dir_id_str, 16)\r
+ else:\r
+ dir_id = int(dir_id_str, 10)\r
\r
global version\r
version = root.get('ver')\r
dirlist = searchdir.BASE(["png", "bmp", "jpg"])\r
dirlist.RecusWalkDir(dir=opt.i)\r
for image in dirlist.fileList:\r
+ img = cv2.imread(image, cv2.IMREAD_UNCHANGED) #返回长宽分辨率元素组\r
+ height = img.shape[0]\r
+ width = img.shape[1]\r
+ if height > 800 or width > 1280:\r
+ print(image," exceeds the maximum pixel size of 1280x800")\r
+ continue\r
if version == '0':\r
converter = Converter(image, g_file_output.get(image), g_file_config.get(image)[1], g_file_config.get(image)[0], \\r
int(g_file_config.get(image)[2]), int(g_file_config.get(image)[3]), int(g_file_config.get(image)[4]), \\r
get_file_config(img_name, img_name)\r
get_file_outputpath(img_name, opt)\r
\r
-dir_id = 1\r
-g_image_resource = []\r
\r
def get_each_dcmpfile_config(opt):\r
dirlist = searchdir.BASE(["bin", "bs"])\r
user_input.t = os.path.abspath(user_input.t)\r
user_input.e = os.path.abspath(user_input.e)\r
user_input.f = os.path.abspath(user_input.f)\r
- process_args(user_input)
\ No newline at end of file
+ process_args(user_input)\r
+\r
+# 记录脚本结束时间\r
+end_time = time.time()\r
+\r
+# 计算并输出运行时间 \r
+execution_time = end_time - start_time\r
+print(f"运行时间: {execution_time:.6f} 秒")
\ No newline at end of file