# Path: flexlay/blitter.py
# def blit_clear(canvas):
#     pass
#     # print("clear(PixelBuffer canvas) not implemented", canvas)
#     # canvas.lock()
#     # buffer = static_cast<unsigned char*>(canvas.get_data())
#     # memset(buffer, 0, sizeof(unsigned char) * canvas.get_pitch() * canvas.height)
#     # canvas.unlock()
# 
# def blit_opaque(target, brush, x, y):
#     painter = QPainter(target.get_qimage())
#     painter.setCompositionMode(QPainter.CompositionMode_Source)
#     painter.drawImage(QPoint(x, y), brush.get_qimage())


from typing import Dict
from PyQt5.QtCore import QSize
from PyQt5.QtGui import QImage
from flexlay.blitter import blit_clear, blit_opaque

        qimg = PixelBuffer.cache.get(filename)
        if qimg is not None:
            pixelbuffer.image = qimg
        else:
            qimg = QImage(filename)
            PixelBuffer.cache[filename] = qimg
            pixelbuffer.image = qimg
            # print("loading:", filename, " -> ", pixelbuffer.image.width(), pixelbuffer.image.height())

        if pixelbuffer.image.isNull():
            assert False, "Failed to load image: {}".format(filename)

        return pixelbuffer

    def __init__(self, width=0, height=0):
        if width != 0 and height != 0:
            self.image = QImage(QSize(width, height), QImage.Format_ARGB32)
        else:
            self.image = None

    def get_qimage(self):
        return self.image

    def lock(self):
        pass

    def unlock(self):
        pass


# Path: flexlay/blitter.py
# def blit_clear(canvas):
#     pass
#     # print("clear(PixelBuffer canvas) not implemented", canvas)
#     # canvas.lock()
#     # buffer = static_cast<unsigned char*>(canvas.get_data())
#     # memset(buffer, 0, sizeof(unsigned char) * canvas.get_pitch() * canvas.height)
#     # canvas.unlock()
# 
# def blit_opaque(target, brush, x, y):
#     painter = QPainter(target.get_qimage())
#     painter.setCompositionMode(QPainter.CompositionMode_Source)
#     painter.drawImage(QPoint(x, y), brush.get_qimage())


# Path: flexlay/pixel_buffer.py
from typing import Dict
from PyQt5.QtCore import QSize
from PyQt5.QtGui import QImage
from flexlay.blitter import blit_clear, blit_opaque


        qimg = PixelBuffer.cache.get(filename)
        if qimg is not None:
            pixelbuffer.image = qimg
        else:
            qimg = QImage(filename)
            PixelBuffer.cache[filename] = qimg
            pixelbuffer.image = qimg
            # print("loading:", filename, " -> ", pixelbuffer.image.width(), pixelbuffer.image.height())

        if pixelbuffer.image.isNull():
            assert False, "Failed to load image: {}".format(filename)

        return pixelbuffer

    def __init__(self, width=0, height=0):
        if width != 0 and height != 0:
            self.image = QImage(QSize(width, height), QImage.Format_ARGB32)
        else:
            self.image = None

    def get_qimage(self):
        return self.image

    def lock(self):
        pass

    def unlock(self):
        pass


    @property