summaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1993-01-20 15:10:05 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1993-01-20 15:10:05 (GMT)
commit9672e44842c59e63920605a4c7ffab7345e73db4 (patch)
treecb20ed48ad5c47605de0e4deb9c0fd4f2bd62df7 /Demo
parent09cbf9a7a668d986fc09babaf3051d3cecd6f749 (diff)
downloadcpython-9672e44842c59e63920605a4c7ffab7345e73db4.zip
cpython-9672e44842c59e63920605a4c7ffab7345e73db4.tar.gz
cpython-9672e44842c59e63920605a4c7ffab7345e73db4.tar.bz2
Create CMIF-video file from SGI rgb images
Diffstat (limited to 'Demo')
-rwxr-xr-xDemo/sgi/video/rgb2video.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/Demo/sgi/video/rgb2video.py b/Demo/sgi/video/rgb2video.py
new file mode 100755
index 0000000..040c1e5
--- /dev/null
+++ b/Demo/sgi/video/rgb2video.py
@@ -0,0 +1,75 @@
+import sys
+import VFile
+import getopt
+import imgfile
+import string
+
+def main():
+ format = None
+ interval = 40
+ outfile = 'film.video'
+
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], 'f:i:o:')
+ except getopt.error:
+ usage()
+ sys.exit(1)
+ for opt, arg in opts:
+ if opt == '-f':
+ format = arg
+ elif opt == '-i':
+ interval = string.atoi(arg)
+ elif opt == '-o':
+ outfile = arg
+ else:
+ usage()
+ sys.exit(1)
+ if not args:
+ usage()
+ sys.exit(1)
+
+ xsize, ysize, zsize = imgfile.getsizes(args[0])
+ nxsize = xsize
+
+ if not format:
+ if zsize == 3:
+ format = 'rgb'
+ elif zsize == 1:
+ format = 'grey'
+ if xsize % 4:
+ addbytes = 4-(xsize%4)
+ nxsize = xsize + addbytes
+ print 'rgb2video: add',addbytes,'pixels per line'
+ else:
+ print 'rgb2video: incorrect number of planes:',zsize
+ sys.exit(1)
+
+ vout = VFile.VoutFile().init(outfile)
+ vout.format = format
+ vout.width = nxsize
+ vout.height = ysize
+ vout.writeheader()
+ t = 0
+ sys.stderr.write('Processing ')
+ for img in args:
+ sys.stderr.write(img + ' ')
+ if imgfile.getsizes(img) <> (xsize, ysize, zsize):
+ print 'rgb2video: Image is different size:', img
+ sys.exit(1)
+ data = imgfile.read(img)
+ if xsize <> nxsize:
+ ndata = ''
+ for i in range(0,len(data), xsize):
+ curline = data[i:i+xsize]
+ ndata = ndata + curline + ('\0'*(nxsize-xsize))
+ data = ndata
+ vout.writeframe(t, data, None)
+ t = t + interval
+ sys.stderr.write('\n')
+ vout.close()
+
+def usage():
+ print 'Usage: rgb2video [-o output] [-i frameinterval] [-f format] rgbfile ...'
+
+main()
+