def textureTest(): help(Reader) r = Reader(file=open('tesx.png')) rgb = list(r.asRGBA()[2]) print len(rgb),len(rgb[0]) img = Image(500,500) drawTexturedTri(150,150,300,100,100,300,1,0,0,1,1,1,rgb,(255,255,0),img) img.savePpm('t.ppm')
def load_image(filename): """Given the file name of a PNG file, create and return an Image object representing the image. """ if not isfile(filename): raise ValueError("file '" + filename + "' cannot be found") reader = Reader(filename) num_cols, num_rows, pixels, _ = reader.asRGBA() rows = [] for row in pixels: # note: each 'row' from this iterator is an array, so we call # its tolist() method here and box it rows.append(_box(row.tolist(), input_type='rgba')) img = Image(num_rows, num_cols) img.image_data = rows return img
def getTexture(texture, texcache): if texture not in texcache: r = Reader(texture) rgb = list(r.asRGBA()[2]) texcache[texture] = rgb return texcache[texture]