From 9fb8fd90dcf9901e0fbadae91d572f184ae5bc8f Mon Sep 17 00:00:00 2001 From: passthem Date: Thu, 2 Oct 2025 12:06:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B1=BB=E5=9E=8B=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- konabot/plugins/roll_dice/roll_dice.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/konabot/plugins/roll_dice/roll_dice.py b/konabot/plugins/roll_dice/roll_dice.py index 96fe54b..1ba529e 100644 --- a/konabot/plugins/roll_dice/roll_dice.py +++ b/konabot/plugins/roll_dice/roll_dice.py @@ -332,9 +332,10 @@ async def generate_dice_image(number: str) -> BytesIO: up_direction = (51 - 16, 5 - 30) # 右上角点 - 左上角点 move_distance = (up_direction[0] * (stretch_k - 1), up_direction[1] * (stretch_k - 1)) - + # 加载背景图像,保留透明通道 - background = cv2.imread(ASSETS_PATH / "img" / "dice" / "template.png", cv2.IMREAD_UNCHANGED) + background = cv2.imread(str(ASSETS_PATH / "img" / "dice" / "template.png"), cv2.IMREAD_UNCHANGED) + assert background is not None height, width = background.shape[:2] @@ -352,7 +353,7 @@ async def generate_dice_image(number: str) -> BytesIO: ], dtype=np.float32) corners[:, 0] += offset_x corners[:, 1] += offset_y - + # 对文本图像进行3D变换(保持透明通道) transformed_text, transform_matrix = perspective_transform(text_image, background, corners)