Not so fast after all. I ended up comparing it with using PIL. Here is a
complete test and the results:
import timeit
from PIL import Image
import cStringIO
myrgba = "rgbaRGBA1234"*512*512
mybgra = ""
def csconv():
global myrgba
global mybgra
input = cStringIO.StringIO(myrgba)
output = cStringIO.StringIO()
c1 = input.read(1)
while c1:
c2 = input.read(1)
c3 = input.read(1)
c4 = input.read(1)
output.write(c3)
output.write(c2)
output.write(c1)
output.write(c4)
c1 = input.read(1)
mybgra = output.getvalue()
def pilconv():
global myrgba
global mybgra
im = Image.fromstring("RGBA", (1536, 512), myrgba, "raw", "BGRA")
mybgra = im.tostring()
t1 = timeit.Timer(csconv)
t2 = timeit.Timer(pilconv)
print "With cStringIO: ", t1.timeit(1)
And the output on my first gen MacBook was
With cStringIO: 4.43397188187
With PIL: 0.0196070671082
_______________________________________________
Pygui mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pygui