mini-arcade-core 0.7.3__py3-none-any.whl → 0.7.5__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,30 @@ 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
+ # Justification: Pillow can raise various exceptions on failure
144
+ # pylint: disable=broad-exception-caught
145
+ except Exception:
146
+ return False
147
+ # pylint: enable=broad-exception-caught
148
+
122
149
  def screenshot(
123
150
  self, label: str | None = None, directory: str = "screenshots"
124
151
  ) -> str | None:
@@ -137,9 +164,11 @@ class Game:
137
164
  os.makedirs(directory, exist_ok=True)
138
165
  stamp = datetime.now().strftime("%Y%m%d_%H%M%S")
139
166
  label = label or "shot"
140
- filename = f"{stamp}_{label}.png"
141
- path = os.path.join(directory, filename)
167
+ filename = f"{stamp}_{label}"
168
+ bmp_path = os.path.join(directory, f"{filename}.bmp")
142
169
 
143
- if self.backend.capture_frame(path):
144
- return path
170
+ if self.backend.capture_frame(bmp_path):
171
+ out_path = Path(directory) / f"{filename}.png"
172
+ self._convert_bmp_to_image(bmp_path, str(out_path))
173
+ return str(out_path)
145
174
  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.5
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=SBhpQnaK5Fs0Y4sV6cV-kciI1hRzyLxix8Sictlc9Eo,5246
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.5.dist-info/METADATA,sha256=mCheuxo7siOALms4OIJDSae1fsNiFwfNNYFygLOF-o8,8324
7
+ mini_arcade_core-0.7.5.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
8
+ mini_arcade_core-0.7.5.dist-info/licenses/LICENSE,sha256=3lHAuV0584cVS5vAqi2uC6GcsVgxUijvwvtZckyvaZ4,1096
9
+ mini_arcade_core-0.7.5.dist-info/RECORD,,