def genColours(cmap, cmapResolution, invert, alpha, gamma=1):
    """Generate an array containing ``cmapResolution`` colours from the given
    colour map object/function.
    """
    import numpy as np
    import matplotlib.cm as cm
    ncols = cmapResolution
    cmap = cm.get_cmap(cmap)
    idxs = np.linspace(0.0, 1.0, ncols)
    if gamma != 1:
        idxs = idxs ** gamma
    if invert:
        idxs = idxs[::-1]
    cmap = cmap(idxs)
    cmap[:, (3)] = alpha
    return np.dstack((cmap, cmap)).transpose((2, 0, 1))
