from visual import * import Image # from the Python Imaging Library (PIL); www.pythonware.com/products/pil im = Image.open("flower.jpg") # read a jpeg file named flower.jpg #print im.size # to see the width and height of the image # optionally crop image with rectangle (x1,y1,x2,y2), where (0,0) is upper left corner: #im = im.crop((0,20,300,320)) #im.show() # optionally display the cropped image im = im.resize((256,256)) # resize so that length and width are powers of 2 # getdata() returns a special sequence, which must be made into a list # before being made into an array: data = array(list(im.getdata()),ubyte) # read pixel data into flat Numeric array data = reshape(data, (256,256,3)) # reshape for rgb texture # texture (0,0) is lower left corner, so flip the y values: im = data[::-1].copy() # copy() is necessary to make array contiguous in memory photo = texture(data=im, type="rgb") box(size=(10,10,0.01), texture=photo, shininess=0) box(pos=(0,-5.5,0), size=(12,1,2), color=color.cyan)