Source

hakanardo / video / negative2.py

import sys
from video import *

fn = sys.argv[1] if len(sys.argv)>1 else 'tv://'

class Neg1(Pixelwise):
    typecode = 'B'
    def op(self, p):
        return 255 - p

def Neg2(img):
    out = img.new()
    for p in img.pixels():
        out[p] = 255 - img[p]
    return out

def genneg(img):
    for p in img:
        yield 255 - p

def Neg3(img):
    out = img.new()
    for i, p in enumerate(genneg(img)):
        out.data[i] = p
    return out

for img in mplayer(fn):
    view(Neg3(img))