Skip to content
Snippets Groups Projects
Verified Commit d740cec3 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: new image method

parent 0da5c767
No related branches found
No related tags found
1 merge request!36Support for Python
This commit is part of merge request !36. Comments created here will be created in the context of that merge request.
from PIL import Image
from PIL.Image import Image, frombytes
from .boytacean import DISPLAY_WIDTH, DISPLAY_HEIGHT, CPU_FREQ, GameBoy as GameBoyRust
......@@ -41,11 +41,13 @@ class GameBoy:
def frame_buffer(self):
return self._system.frame_buffer()
def save_image(self, filename: str, format: str = "PNG"):
def image(self) -> Image:
frame_buffer = self._system.frame_buffer()
image = Image.frombytes(
"RGB", (DISPLAY_WIDTH, DISPLAY_HEIGHT), frame_buffer, "raw"
)
image = frombytes("RGB", (DISPLAY_WIDTH, DISPLAY_HEIGHT), frame_buffer, "raw")
return image
def save_image(self, filename: str, format: str = "PNG"):
image = self.image()
image.save(filename, format=format)
@property
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment