This is the funtion I am using to push the image to the screen:
Code: Select all
def draw_image(self, path, x=0, y=0, w=320, h=240, chunk_height=3200):
"""Draw image from flash.
Args:
path (string): Image file path.
x (int): X coordinate of image left. Default is 0.
y (int): Y coordinate of image top. Default is 0.
w (int): Width of image. Default is 320.
h (int): Height of image. Default is 240.
"""
x2 = x + w - 1
y2 = y + h - 1
with open(path, "rb") as f:
chunk_height = chunk_height // w
chunk_count, remainder = divmod(h, chunk_height)
chunk_size = chunk_height * w * 2
chunk_y = y
buf = bytearray(chunk_size)
if chunk_count:
for c in range(0, chunk_count):
f.readinto(buf, chunk_size)
self.block(x, chunk_y,
x2, chunk_y + chunk_height - 1,
buf)
chunk_y += chunk_height
if remainder:
f.readinto(buf, remainder * w * 2)
self.block(x, chunk_y,
x2, chunk_y + remainder - 1,
buf)
Does anyone know how this can be achieved?
Thanks in advance