Statistics
| Revision:

root / PyOpenGL-Demo / dek / PILNumeric.py @ 1

History | View | Annotate | Download (1.1 kB)

1
# This is statement is required by the build system to query build info
2
if __name__ == '__build__':
3
        raise Exception
4

    
5
## This isn't really a PyOpenGL demo, but it's a nice
6
## example of how Numeric, Tkinter, and PIL can be used 
7
## together to create all sorts of images.
8
try:
9
        import numpy as Numeric
10
except ImportError, err:
11
        try: 
12
                import Numeric
13
        except ImportError, err:
14
                print "This demo requires the numpy or Numeric extension, sorry"
15
                import sys
16
                sys.exit()
17
import FFT
18
import Tkinter
19
import Image
20
import ImageTk
21
import sys
22

    
23
w = 256
24
h = 256
25

    
26
    
27
def demo():
28
    data = Numeric.arrayrange(w*h)
29

    
30
##    fftdata = FFT.fft(data)
31
##    fftdata2 = FFT.fft(data2)
32
##    fftdata3 = (fftdata + fftdata2) / 2.
33
##    invfftdata = FFT.inverse_fft(fftdata3)
34
##    data = invfftdata.real
35
    data = data.astype('l')
36

    
37
    im = Image.new("RGBA", (w, h))
38
    print len(data.tostring("raw", "RGBX", 0, -1))
39
    print len(im.tostring("raw", "RGBX", 0, -1))
40
    im.fromstring(data.tostring("raw", "RGBX", 0, -1),"raw", "RGBX", 0, -1)
41

    
42
    root = Tkinter.Tk()
43
    image = ImageTk.PhotoImage(im)
44
    x = Tkinter.Label(root, image=image)
45
    x.pack()
46

    
47
    root.mainloop()