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?