Skip to content

Commit

Permalink
Fix image didn't fill screen area issue
Browse files Browse the repository at this point in the history
  • Loading branch information
YayunHuang committed Aug 21, 2024
1 parent 8c31e9b commit 11d9b11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mockup_package/mockup/image_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,16 @@ def create_mockup_image(self, device_path, device_mask_path_prefix, result_path)
tmp = self.target_points[0].copy()
self.target_points[0] = self.target_points[1]
self.target_points[1] = tmp
shifted_points = self.target_points + np.array([PADDING, PADDING])
mask = np.zeros(basemap.shape[:2], np.uint8)
cv2.polylines(
mask,
pts=[self.target_points],
pts=[shifted_points],
isClosed=True,
color=(255, 0, 0),
thickness=3,
)
cv2.fillPoly(mask, [self.target_points], 255)
cv2.fillPoly(mask, [shifted_points], 255)
mask = cv2.cvtColor(mask, cv2.COLOR_BGR2RGBA)
mask = Image.fromarray(mask)

Expand All @@ -209,7 +210,9 @@ def create_mockup_image(self, device_path, device_mask_path_prefix, result_path)
# If you want to use the mask directly with the first argument of the "paste" function, # noqa: E501
# you need to convert it to the "L" mode and ensure that it has the same size as the first argument. # noqa: E501
device_image.paste(
tmp_result_image, (self.xyset[0], self.xyset[2]), mask.convert("L")
tmp_result_image,
(self.xyset[0] - PADDING, self.xyset[2] - PADDING),
mask.convert("L"),
)
device_image.save(result_path)

Expand Down
Binary file modified public/mockup.zip
Binary file not shown.

0 comments on commit 11d9b11

Please sign in to comment.