1 |
# A module for saving an image frame from the current front buffer |
# Saving demo sequences |
2 |
|
|
3 |
from java.io import FileOutputStream |
from gzz.util import saveimage |
4 |
from gzz.gfx.gl import GL |
from gzz.gfx.gl import GL |
5 |
import os |
import os |
6 |
|
|
7 |
def save(): |
def saveframe(filename, win): |
8 |
x,y = 0,0 |
x,y = 0,0 |
9 |
s = win.getSize() |
s = win.getSize() |
10 |
colors = win.readPixels(0, 0, s.width, s.height) |
pix = win.readPixels(0, 0, s.width, s.height) |
11 |
|
saveimage.save(filename, pix, s.width, s.height) |
12 |
|
|
13 |
def savesequence(win, filebase, vs1, vs2, n): |
def savesequence(win, filebase, vs1, vs2, n): |
14 |
for frame in range(0, n+1): |
for frame in range(0, n+1): |
15 |
fract = frame / (n+0.0) |
fract = frame / (n+0.0) |
16 |
win.renderAnim(vs1, vs2, fract, 0, 1) |
win.renderAnim(vs1, vs2, fract, 0, 1) |
17 |
saveframe(filebase + "%03d"%frame + ".jpg", win) |
saveframe(filebase + "%03d"%frame + ".jpg", win) |
18 |
|
|
19 |
|
def encodefilm(globpat, outfilm): |
20 |
|
mencoder = "/BIG/MPlayer-0.90pre8/mencoder" |
21 |
|
os.system("%(mencoder)s %(globpat)s -lavcopts vcodec=mpeg4 -mf on:fps=25 -ovc lavc -o %(outfilm)s" |
22 |
|
% locals()) |
23 |
|
|