Raw image sequence assignment: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 38: Line 38:
</source>
</source>


http://i.imgur.com/m0GBwAz.gif


http://i.imgur.com/hkUE09l.gif
with Michael...

Latest revision as of 01:44, 5 December 2013

 # rawimagesequence.py
import struct, sys

width = 320
height = 240
header = struct.pack("<BBBHHBHHHHBB",0,0,2,0,0,8,0,0,width,height,32,1<<5)

totalframes = 25
 def map(x, startend, newstartnewend):
   start, end = startend
   newstart, newend = newstartnewend
   p = (float(x) - start) / (end - start)
   return newstart + (p * (newend-newstart))
   
for frame in xrange(totalframes):
   out = open("frame%02d.tga" % frame, "wb")
   out.write(header)

   for y in xrange(height):
       for x in xrange(width):
           r =  map(frame, (0, totalframes), (255, 0))
           g =  map(frame, (0, totalframes), (0, 255))
           b = 0
           a = 255

           out.write(struct.pack('B', b))
           out.write(struct.pack('B', g))
           out.write(struct.pack('B', r))
           out.write(struct.pack('B', a))
   print r

   out.close()
   
import os
os.system("convert frame* nik.gif")

m0GBwAz.gif

with Michael...