# Path: canvas/lib/uint8clampedarray.py
# class Uint8ClampedArray(array):
#     def __new__(cls, size=0):
#         return array.__new__(cls, 'B', [0] * size)
# 
#     def __getitem__(self, key):
#         return array.__getitem__(self, key)
# 
#     def __setitem__(self, key, value):
#         if value < 0:
#             value = 0
#         elif value > 255:
#             value = 255
#         return array.__setitem__(self, key, value)


from canvas.lib.uint8clampedarray import Uint8ClampedArray
    Parameters

        width
            The width to give the new ImageData object.

        height
            The height to give the new ImageData object.

        imagedata
            An existing ImageData object from which to copy the width and
            height. The image itself is not copied.

    Return value

        A new ImageData object with the specified width and height. The new
        object is filled with transparent black pixels.

    Errors thrown

        IndexSizeError
            Thrown if either of the width or height arguments are zero.
    """
    def __init__(self, sw=0, sh=0, data=None):
        if isinstance(data, ImageData):
            sw = data.width
            sh = data.height

        if sw is 0 or sh is 0:
            raise IndexSizeError()


# Path: canvas/lib/uint8clampedarray.py
# class Uint8ClampedArray(array):
#     def __new__(cls, size=0):
#         return array.__new__(cls, 'B', [0] * size)
# 
#     def __getitem__(self, key):
#         return array.__getitem__(self, key)
# 
#     def __setitem__(self, key, value):
#         if value < 0:
#             value = 0
#         elif value > 255:
#             value = 255
#         return array.__setitem__(self, key, value)


# Path: canvas/lib/imagedata.py
from canvas.lib.uint8clampedarray import Uint8ClampedArray

    Parameters

        width
            The width to give the new ImageData object.

        height
            The height to give the new ImageData object.

        imagedata
            An existing ImageData object from which to copy the width and
            height. The image itself is not copied.

    Return value

        A new ImageData object with the specified width and height. The new
        object is filled with transparent black pixels.

    Errors thrown

        IndexSizeError
            Thrown if either of the width or height arguments are zero.
    """
    def __init__(self, sw=0, sh=0, data=None):
        if isinstance(data, ImageData):
            sw = data.width
            sh = data.height

        if sw is 0 or sh is 0:
            raise IndexSizeError()


        data = Uint8ClampedArray(sw * sh * 4)