[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Depth Screenshot



On Tue, Oct 6, 2009 at 7:43 PM, Ian Mallett <geometrian@xxxxxxxxx> wrote:
The issue is that in the case of depth, data is of length x*y.  In the case of RGB color, it is 3*rect[2]*rect[3].  In the case of RGBA, it is 4*rect[2]*rect[3].  PyGame doesn't know how to convert it (there's no pygame.image.fromstring(data,size,'R',1), for instance).  What's a decent way to save the depth as an image? 

have you tried a paletted image? they are one byte per pixel.

so:
pygame.image.fromsring(data, size, "P", 1)

another option would be to try python's "array" module - can you array,fromstring(data, "B")? if so, that will let you index the bytes yourself to do whatever you want with them.