X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka_Displayio.git/blobdiff_plain/fd69c0e2397b5665769baceabf902fea01b81008..b39699fa4b1ed4838b72d068f0c13fdf62ef95de:/displayio/_tilegrid.py diff --git a/displayio/_tilegrid.py b/displayio/_tilegrid.py index dc392b9..9287e98 100644 --- a/displayio/_tilegrid.py +++ b/displayio/_tilegrid.py @@ -319,7 +319,7 @@ class TileGrid: ) # In Pixels # Check the mask first to see if the pixel has already been set - if mask[offset // 8] & (1 << (offset % 8)): + if mask[offset // 32] & (1 << (offset % 32)): continue local_x = input_pixel.x // self._absolute_transform.scale tile_location = ( @@ -363,24 +363,24 @@ class TileGrid: if not output_pixel.opaque: full_coverage = False else: - mask[offset // 8] |= 1 << (offset % 8) + mask[offset // 32] |= 1 << (offset % 32) # print("Mask", mask) if colorspace.depth == 16: struct.pack_into( "H", - buffer, - offset * 2, + buffer.cast("H"), + offset, output_pixel.pixel, ) elif colorspace.depth == 32: struct.pack_into( "I", buffer, - offset * 4, + offset, output_pixel.pixel, ) elif colorspace.depth == 8: - buffer[offset] = output_pixel.pixel & 0xFF + buffer.cast("B")[offset] = output_pixel.pixel & 0xFF elif colorspace.depth < 8: # Reorder the offsets to pack multiple rows into # a byte (meaning they share a column). @@ -392,14 +392,16 @@ 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 if colorspace.reverse_pixels_in_byte: # 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 + buffer.cast("B")[offset // pixels_per_byte] |= ( + output_pixel.pixel << shift + ) return full_coverage