adapt for rust render
This commit is contained in:
parent
ad83def45e
commit
7fed4032e0
@ -362,7 +362,7 @@ class SR1ShipRender(BaseScreen):
|
|||||||
# 这个功能依赖于 DR rs (简称,我懒得在Python端实现)
|
# 这个功能依赖于 DR rs (简称,我懒得在Python端实现)
|
||||||
return
|
return
|
||||||
img_box = self.rust_ship.img_pos
|
img_box = self.rust_ship.img_pos
|
||||||
img_size = (img_box[2] - img_box[0] + 1000, img_box[3] - img_box[1] + 1000)
|
img_size = (img_box[2] - img_box[0], img_box[3] - img_box[1])
|
||||||
# 中心点是左上角坐标
|
# 中心点是左上角坐标
|
||||||
img_center = (abs(img_box[0]), abs(img_box[3]))
|
img_center = (abs(img_box[0]), abs(img_box[3]))
|
||||||
try:
|
try:
|
||||||
@ -372,24 +372,30 @@ class SR1ShipRender(BaseScreen):
|
|||||||
print('PIL not found')
|
print('PIL not found')
|
||||||
return
|
return
|
||||||
img = Image.new('RGBA', img_size)
|
img = Image.new('RGBA', img_size)
|
||||||
for part, sprite in self.parts_sprite.items():
|
part_data = self.rust_ship.as_dict()
|
||||||
sprite_img = sprite.image
|
for part, sprites in self.parts_sprite.items():
|
||||||
print(f"sprite_img: {sprite_img} {sprite_img.width} {sprite_img.height}")
|
for index, sprite in enumerate(sprites):
|
||||||
img_data = sprite_img.get_image_data()
|
sprite_img = sprite.image
|
||||||
fmt = img_data.format
|
print(f"sprite_img: {sprite_img} {part_data[part][index][1].x * 60} {part_data[part][index][1].y * 60}")
|
||||||
if fmt != 'RGB':
|
img_data = sprite_img.get_image_data()
|
||||||
fmt = 'RGBA'
|
fmt = img_data.format
|
||||||
pitch = -(img_data.width * len(fmt))
|
if fmt != 'RGB':
|
||||||
pil_image = Image.frombytes(fmt, (img_data.width, img_data.height), img_data.get_data(fmt, pitch))
|
fmt = 'RGBA'
|
||||||
pil_image = pil_image.rotate(SR1Rotation.get_rotation(self.part_data[part].angle), expand=True)
|
pitch = -(img_data.width * len(fmt))
|
||||||
if self.part_data[part].flip_y:
|
pil_image = Image.frombytes(fmt, (img_data.width, img_data.height), img_data.get_data(fmt, pitch))
|
||||||
pil_image.transpose(Image.FLIP_TOP_BOTTOM)
|
|
||||||
if self.part_data[part].flip_x:
|
pil_image = pil_image.rotate(-SR1Rotation.get_rotation(part_data[part][index][1].angle), expand=True)
|
||||||
pil_image.transpose(Image.FLIP_LEFT_RIGHT)
|
|
||||||
img.paste(pil_image, (
|
if part_data[part][index][1].flip_y:
|
||||||
int(self.part_data[part].x * 60 + img_center[0]),
|
pil_image.transpose(Image.FLIP_TOP_BOTTOM)
|
||||||
int(-self.part_data[part].y * 60 + img_center[1])),
|
if part_data[part][index][1].flip_x:
|
||||||
pil_image)
|
pil_image.transpose(Image.FLIP_LEFT_RIGHT)
|
||||||
|
pil_image.show()
|
||||||
|
|
||||||
|
img.paste(pil_image, (
|
||||||
|
int(part_data[part][index][1].x * 60 + img_center[0]),
|
||||||
|
int(-part_data[part][index][1].y * 60 + img_center[1])))
|
||||||
|
img.show("???")
|
||||||
img.save(f'test{time.time()}.png', 'PNG')
|
img.save(f'test{time.time()}.png', 'PNG')
|
||||||
|
|
||||||
elif command.find('test'):
|
elif command.find('test'):
|
||||||
|
Loading…
Reference in New Issue
Block a user