Raw gif

From XPUB & Lens-Based wiki

Rawgif-chen.gif

raw

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
 
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):
            if x >= 120:
                r = 0
                g = 255*(1 - float(frame)/totalframes)
                b = 143*(1 - float(frame)/totalframes)
                a = 255
                    
            if  x < 120:
                r = 255*(float(frame)/totalframes)
                g = 255
                b = 255 - (112/25)*(float(frame)) 
                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))
 
    out.close()