根据站内各位大佬的帖子成功解包了交错战线
但是导入spine后却是这样的
我在spine查看器里都没问题
所以我觉得应该是解纹理时的问题,但是我不知道怎么解决

大佬们,求教
交错战线spine:通过百度网盘分享的文件:4.20更新.z…等2个文件
链接:https://pan.baidu.com/s/1iBhNH5jcPRWhpDK75sWugg
提取码:4t7p
复制这段内容打开「百度网盘APP 即可获取」
检查一下图片尺寸是否正确,你用那个查看器自带尺寸缩放,所以显示正常
怎么检查?
打开atlas文件,图片名的下一行是图片尺寸
是学习版但没改版本吧,解出来是没后缀的我手动添了个.json
版本要大于等于3.8.99不然可能出错spine经常改一些莫名其妙的东西约束那些的
原来如此
我还没注意到这个不一样
from pathlib import Path
from typing import Literal
from SpineAtlas import ReadAtlasFile,ImgPremultiplied
import os
import re
import chardet
from PIL import Image
from PIL.Image import open as imgop
def detect_file_encoding(file_path):
with open(file_path, 'rb') as f:
raw_data = f.read()
result = chardet.detect(raw_data)
return result['encoding']
def process_atlas_files(file_path):
# 遍历当前目录下的所有子文件夹
for root, dirs, files in os.walk(file_path):
# 查找所有.atlas文件
for file in files:
if file.endswith('.atlas'):
atlas_path = os.path.join(root, file)
try:
# 自动检测文件编码
encoding = detect_file_encoding(atlas_path)
if not encoding:
encoding = 'utf-8' # 默认使用UTF-8
# 读取.atlas文件内容
with open(atlas_path, 'r', encoding=encoding) as f:
atlas_content = f.read()
# 使用正则表达式找出所有被引用的PNG文件及其尺寸
png_entries = re.finditer(r'^(.*\.png)\nsize:(\d+),(\d+)', atlas_content, re.MULTILINE)
for entry in png_entries:
png_file = entry.group(1)
atlas_width = int(entry.group(2))
atlas_height = int(entry.group(3))
png_path = os.path.join(root, png_file)
# 检查对应的PNG文件是否存在
if not os.path.exists(png_path):
print(f"Warning: PNG file {png_file} not found in {root}")
continue
# 打开PNG图片并获取实际尺寸
try:
with Image.open(png_path) as img:
original_width, original_height = img.size
# 检查是否需要调整大小
if (original_width, original_height) == (atlas_width, atlas_height):
print(f"No resize needed for {png_file}")
continue
# 调整图片大小
print(
f"Resizing {png_file} from {original_width}x{original_height} to {atlas_width}x{atlas_height}")
resized_img = img.resize((atlas_width, atlas_height), Image.LANCZOS)
# 保存调整后的图片(覆盖原文件)
resized_img.save(png_path)
print(f"Successfully resized {png_file}")
except Exception as img_error:
print(f"Error processing {png_file}: {str(img_error)}")
except Exception as e:
print(f"Error processing {atlas_path}: {str(e)}")
continue
def batch(fp: str = '', mode: Literal['Normal', 'Premul', 'NonPremul'] = 'Normal', scale: bool = True, subfolder: bool = True):
path = Path(fp) if fp else Path.cwd()
need = [i for i in (path.rglob('*.atlas') if subfolder else path.glob('*.atlas')) if i.is_file()]
for i in need:
print(f' {i.as_posix()},{i.parent.joinpath(i.stem)}')
try:
atlas = ReadAtlasFile(i)
except:
print(f'读取Atlas错误 --- {i.as_posix()}')
continue
atlas.ReScale()
atlas.SaveFrames(i.parent.joinpath("images"), mode=mode)#.joinpath("images")
def rename_second_level_to_images(root_dir):
# 遍历当前目录下的直接子文件夹(第一层)
for first_level_dir in os.listdir(root_dir):
first_level_path = os.path.join(root_dir, first_level_dir)
# 确保是文件夹(跳过文件)
if not os.path.isdir(first_level_path):
continue
# 遍历第一层目录下的直接子文件夹(第二层)
for second_level_dir in os.listdir(first_level_path):
second_level_path = os.path.join(first_level_path, second_level_dir)
# 确保是文件夹(跳过文件)
if not os.path.isdir(second_level_path):
continue
# 构造新的目标路径(重命名为 images)
new_path = os.path.join(first_level_path, 'images')
try:
# 如果目标路径已存在,先删除(可选,根据需求调整)
if os.path.exists(new_path):
print(f'Skipping: {second_level_path} (images already exists)')
continue
# 执行重命名
os.rename(second_level_path, new_path)
print(f'Renamed: {second_level_path} -> {new_path}')
except Exception as e:
print(f'Error renaming {second_level_path}: {e}')
def convert_pngs_to_premultiplied(root_dir):
for root, dirs, files in os.walk(root_dir):
for file in files:
if file.lower().endswith('.png'):
png_path = os.path.join(root, file)
try:
# 打开原始图片
img = imgop(png_path)
# 转换为Premultiplied
tex = ImgPremultiplied(img)
# 删除原始文件
os.remove(png_path)
# 保存新文件(使用与原始文件相同的路径)
tex.save(png_path)
print(f"已处理: {png_path}")
except Exception as e:
print(f"处理 {png_path} 时出错: {str(e)}")
if __name__ == '__main__':
path = input(">") # atlas在pc上的路径
#convert_pngs_to_premultiplied(path)
#process_atlas_files(path)
mode = 'Premul' # ['Normal', 'Premul', 'NonPremul'] Normal - 不做任何处理, Premul - 将贴图转换为预乘, NonPremul - 将贴图转换为非预乘
scale = True # 当贴图尺寸与atlas记录的贴图尺寸不符合时 重新计算帧的范围
subfolder = True # 是否查找子文件夹内的atlas
batch(path, mode, scale, subfolder)
#rename_second_level_to_images(path)
批量解包代码之前站内一个大佬给的
一般特别大的很多游戏都会改png大小进行缩放