]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_tilegrid.py
bug fixes
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _tilegrid.py
index 6705601681d16bae4a6ad9ce820847d44aa478f1..a87860eff7f7e8f2eb376fd7285c612243f42867 100644 (file)
@@ -363,19 +363,18 @@ class TileGrid:
                 if not output_pixel.opaque:
                     full_coverage = False
                 else:
-                    mask[offset // 8] |= 1 << (offset % 8)
-                    # print("Mask", mask)
+                    mask[offset // 32] |= 1 << (offset % 32)
                     if colorspace.depth == 16:
                         struct.pack_into(
                             "H",
-                            buffer,
+                            buffer.cast("B"),
                             offset * 2,
                             output_pixel.pixel,
                         )
                     elif colorspace.depth == 32:
                         struct.pack_into(
                             "I",
-                            buffer,
+                            buffer.cast("B"),
                             offset * 4,
                             output_pixel.pixel,
                         )
@@ -392,7 +391,7 @@ class TileGrid:
                             # even if we multiply it back out
                             offset = (
                                 col * pixels_per_byte
-                                + (row // pixels_per_byte) * width
+                                + (row // pixels_per_byte) * pixels_per_byte * width
                                 + (row % pixels_per_byte)
                             )
                         shift = (offset % pixels_per_byte) * colorspace.depth
@@ -400,6 +399,7 @@ class TileGrid:
                             # Reverse the shift by subtracting it from the leftmost shift
                             shift = (pixels_per_byte - 1) * colorspace.depth - shift
                         buffer[offset // pixels_per_byte] |= output_pixel.pixel << shift
+
         return full_coverage
 
     def _finish_refresh(self):