43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
# Copyright (c) 2017-2020 Richard Hull and contributors
|
|
# See LICENSE.rst for details.
|
|
# PYTHON_ARGCOMPLETE_OK
|
|
|
|
"""
|
|
Displays an animated gif.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
from demo_opts import get_device
|
|
from PIL import Image, ImageSequence, ImageOps
|
|
from luma.core.sprite_system import framerate_regulator
|
|
|
|
|
|
def main():
|
|
regulator = framerate_regulator(fps=45)
|
|
img_path = str(Path(__file__).resolve().parent.joinpath('images', 'inverted_cat_s.gif'))
|
|
banana = Image.open(img_path)
|
|
size = [min(*device.size)] * 2
|
|
posn = ((device.width - size[0]) // 2, device.height - size[1])
|
|
|
|
while True:
|
|
for frame in ImageSequence.Iterator(banana):
|
|
with regulator:
|
|
#background = Image.new("RGBA", device.size, "black")
|
|
#background.paste(frame.resize(size, resample=Image.LANCZOS), posn)
|
|
#device.mode = "1"
|
|
#device.display(background.convert(device.mode))
|
|
|
|
|
|
device.display(frame.convert(device.mode))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
device = get_device()
|
|
main()
|
|
except KeyboardInterrupt:
|
|
pass
|
|
|