I want to send an image Pixbuf over a socket but the received image is only in black and white and distorted. Here are the steps I'm using:
1) get pixels array of that Pixbuf
2) serialize the pixels array
3) Convert the serialized string to a BytesIO
4) Send over the socket
MyShot = ScreenShot2()
frame = MyShot.GetScreenShot() #this function returns the Pixbuf
a = frame.get_pixels_array()
Sframe = pickle.dumps( a, 1)
b = BytesIO()
b.write(Sframe)
b.seek(0)
after this I have to rebuild the image by:
1) Deserialize the received string in its original pixels array
2) Build the Pixbuf from the pixels array
3) Save the image
res = gtk.gdk.pixbuf_new_from_data(pickle.loads(b.getvalue()), frame.get_colorspace(), False, frame.get_bits_per_sample(), frame.get_width(), frame.get_height(), frame.get_rowstride()) #also tried this res = gtk.gdk.pixbuf_new_from_array(pickle.loads(b.read()),gtk.gdk.COLORSPACE_RGB,8)
res.save("result.png","png")