Skip to content

Screenshots ​

RGB images ​

python
from mrkwatkins.oakemu.zxspectrum import ZXSpectrum

spectrum = ZXSpectrum()
spectrum.execute_frame()
rgb = spectrum.screen.get_rgb_screenshot()
print(rgb.shape)

The result is a NumPy array of unsigned bytes with shape (height, width, 3). The last dimension contains red, green and blue values.

The default fast screen gives a (192, 256, 3) image. Other screen implementations can include a border, so use the returned shape rather than assuming fixed dimensions.

To save the array with the optional imageio package:

python
import imageio.v3 as iio

iio.imwrite("screen.png", rgb)

Palette indexes ​

python
pixels = spectrum.screen.get_pixel_colour_screenshot()
print(pixels.shape)

This returns a (height, width) array of palette indexes. ZXColour names the eight base colours. Screenshots are copies; editing the arrays does not change the emulator.

Screen settings ​

python
from mrkwatkins.oakemu.zxspectrum import ZXColour

spectrum.screen.border = ZXColour.BLUE
print(spectrum.screen.renders_border)
print(spectrum.screen.renders_flash)

Use ScreenType.ACCURATE when creating the machine to render border and flashing effects. The fast screen does not render either effect.

Raw screen memory ​

python
screen_bytes = spectrum.get_screen_memory()

This returns a one-dimensional copy of the 6912 screen-memory bytes. They remain in ZX Spectrum bitmap and attribute layout; use a screenshot method when you need a normal image array.