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)