示例#1
0
def image_to_string(filename):
    """Generate a string representation of the image at the given path, for embedding in code."""
    image = pyglet.image.load(filename)
    data = image.get_data('LA', 16)
    s = ''
    for x in data:
        s += "\\x%02x" % (ord(x))
    return s
def image_to_string(filename):
    """Generate a string representation of the image at the given path, for embedding in code."""
    image = pyglet.image.load(filename)
    data = image.get_data('LA', 16)
    s = ''
    for x in data:
        s += "\\x%02x" % (ord(x))
    return s
示例#3
0
def get_data(image):
    """Retrieve pixel data from an image as 4 lists of bytestrings"""
    array = [list(ord(n) for n in image.get_data(c, image.width))
        for c in 'RGBA']
    return array