mini-arcade-core 0.7.3__py3-none-any.whl → 0.7.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mini_arcade_core/game.py CHANGED
@@ -7,9 +7,12 @@ from __future__ import annotations
7
7
  import os
8
8
  from dataclasses import dataclass
9
9
  from datetime import datetime
10
+ from pathlib import Path
10
11
  from time import perf_counter, sleep
11
12
  from typing import TYPE_CHECKING
12
13
 
14
+ from PIL import Image # type: ignore[import]
15
+
13
16
  from .backend import Backend
14
17
 
15
18
  if TYPE_CHECKING: # avoid runtime circular import
@@ -119,6 +122,27 @@ class Game:
119
122
  if self._current_scene is not None:
120
123
  self._current_scene.on_exit()
121
124
 
125
+ @staticmethod
126
+ def _convert_bmp_to_image(bmp_path: str, out_path: str) -> bool:
127
+ """
128
+ Convert a BMP file to another image format using Pillow.
129
+
130
+ :param bmp_path: Path to the input BMP file.
131
+ :type bmp_path: str
132
+
133
+ :param out_path: Path to the output image file.
134
+ :type out_path: str
135
+
136
+ :return: True if conversion was successful, False otherwise.
137
+ :rtype: bool
138
+ """
139
+ try:
140
+ img = Image.open(bmp_path)
141
+ img.save(out_path) # Pillow chooses format from extension
142
+ return True
143
+ except Exception:
144
+ return False
145
+
122
146
  def screenshot(
123
147
  self, label: str | None = None, directory: str = "screenshots"
124
148
  ) -> str | None:
@@ -137,9 +161,11 @@ class Game:
137
161
  os.makedirs(directory, exist_ok=True)
138
162
  stamp = datetime.now().strftime("%Y%m%d_%H%M%S")
139
163
  label = label or "shot"
140
- filename = f"{stamp}_{label}.png"
141
- path = os.path.join(directory, filename)
164
+ filename = f"{stamp}_{label}"
165
+ bmp_path = os.path.join(directory, f"{filename}.bmp")
142
166
 
143
- if self.backend.capture_frame(path):
144
- return path
167
+ if self.backend.capture_frame(bmp_path):
168
+ out_path = Path(directory) / f"{filename}.png"
169
+ self._convert_bmp_to_image(bmp_path, str(out_path))
170
+ return str(out_path)
145
171
  return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mini-arcade-core
3
- Version: 0.7.3
3
+ Version: 0.7.4
4
4
  Summary: Tiny scene-based game loop core for small arcade games.
5
5
  License: Copyright (c) 2025 Santiago Rincón
6
6
 
@@ -34,6 +34,7 @@ Provides-Extra: dev
34
34
  Requires-Dist: black (>=24.10,<25.0) ; extra == "dev"
35
35
  Requires-Dist: isort (>=5.13,<6.0) ; extra == "dev"
36
36
  Requires-Dist: mypy (>=1.5,<2.0) ; extra == "dev"
37
+ Requires-Dist: pillow (<12)
37
38
  Requires-Dist: pylint (>=3.3,<4.0) ; extra == "dev"
38
39
  Requires-Dist: pytest (>=8.3,<9.0) ; extra == "dev"
39
40
  Requires-Dist: pytest-cov (>=6.0,<7.0) ; extra == "dev"
@@ -1,9 +1,9 @@
1
1
  mini_arcade_core/__init__.py,sha256=0gkloHYTV8FmEZbBLxNNy-eJge2y7pkQ_PCcrfeJ3uo,1831
2
2
  mini_arcade_core/backend.py,sha256=SvsHDO0Fq86buTqMkOCSAidx2E4QAJ6mLsSa9ZQXEqY,4514
3
3
  mini_arcade_core/entity.py,sha256=mAkedH0j14giBQFRpQjaym46uczbQDln6nbxy0WFAqU,1077
4
- mini_arcade_core/game.py,sha256=B65cX1TNPEsB7UUATH6Qz86CN0L2Te6TaSC2wi1qqdo,4227
4
+ mini_arcade_core/game.py,sha256=qfJ4UiAA2Mu-iAkj5SvxWxteGO9-s79IjlJk9ORHliw,5077
5
5
  mini_arcade_core/scene.py,sha256=QENcn2hWUF3Ja9pU8NK67NYmC8ptnjdpUkg1qsUEl60,2435
6
- mini_arcade_core-0.7.3.dist-info/METADATA,sha256=QQnu-0nkALgs97hDf9lqLgcWw1CxueLtfr-6locLheE,8296
7
- mini_arcade_core-0.7.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
8
- mini_arcade_core-0.7.3.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
9
- mini_arcade_core-0.7.3.dist-info/RECORD,,
6
+ mini_arcade_core-0.7.4.dist-info/METADATA,sha256=3-lnmTd16f89QKre5WegNgd8xQ2fR4MoY5ZrCB1A2n4,8324
7
+ mini_arcade_core-0.7.4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
8
+ mini_arcade_core-0.7.4.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
9
+ mini_arcade_core-0.7.4.dist-info/RECORD,,