From d1a6c1abf695b24093f366f2be3c5c8b5ad449f8 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Tue, 10 Aug 2021 23:37:08 +0000 Subject: [PATCH] Change to a slightly different (but probably equivalent) method of doing masking to avoid messing with the mask transform. --- bemani/format/afp/render.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bemani/format/afp/render.py b/bemani/format/afp/render.py index cb0b79f..4421351 100644 --- a/bemani/format/afp/render.py +++ b/bemani/format/afp/render.py @@ -1039,10 +1039,17 @@ class AFPRenderer(VerboseOutput): ) -> Image.Image: if mask.rectangle is None: # Calculate the new mask rectangle. - mask.rectangle = Image.new('RGBA', (int(mask.bounds.width), int(mask.bounds.height)), (255, 0, 0, 255)) - - # Offset it by its top/left. - transform = transform.translate(Point(mask.bounds.left, mask.bounds.top)) + mask.rectangle = affine_composite( + Image.new('RGBA', (int(mask.bounds.right), int(mask.bounds.bottom)), (0, 0, 0, 0)), + Color(0.0, 0.0, 0.0, 0.0), + Color(1.0, 1.0, 1.0, 1.0), + Matrix.identity().translate(Point(mask.bounds.left, mask.bounds.top)), + None, + 0, + Image.new('RGBA', (int(mask.bounds.width), int(mask.bounds.height)), (255, 0, 0, 255)), + single_threaded=self.__single_threaded, + aa_mode=AAMode.NONE, + ) # Draw the mask onto a new image. if projection == AP2PlaceObjectTag.PROJECTION_AFFINE: