1 # SPDX-FileCopyrightText: 2020 Melissa LeBlanc-Williams for Adafruit Industries
3 # SPDX-License-Identifier: MIT
6 `displayio.ondiskbitmap`
7 ================================================================================
11 **Software and Dependencies:**
14 https://github.com/adafruit/Adafruit_Blinka/releases
16 * Author(s): Melissa LeBlanc-Williams
22 __version__ = "0.0.0-auto.0"
23 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"
28 Loads values straight from disk. This minimizes memory use but can lead to much slower
29 pixel load times. These load times may result in frame tearing where only part of the
32 def __init__(self, file):
33 self._image = Image.open(file).convert("RGBA")
37 """Width of the bitmap. (read only)"""
38 return self._image.width
42 """Height of the bitmap. (read only)"""
43 return self._image.height
45 def __getitem__(self, index):
47 Returns the value at the given index. The index can either be
48 an x,y tuple or an int equal to `y * width + x`.
50 if isinstance(index, (tuple, list)):
53 elif isinstance(index, int):
54 x = index % self._image._width
55 y = index // self._image._width
56 if not 0 <= x < self._image.width or not 0 <= y < self._image.height:
59 return self._image.getpixel((x, y))