Hi,
I am trying to send a screenshot of my window over serial to another screen.
I have done the following to get the screenshot:
self.pp = PNMImage()
if(base.win.getScreenshot(self.pp)):
self.pp = PNMImage(320, 240, self.pp.getNumChannels())
And when I try writing this to file it is fine and looks how it should.
I am using PySerial and that works fine for sending bytes over serial to my hardware such as strings etc. but I want to send over the PNMImage.
I saw a thread [url]PNMImage.write Arguments Make No Sense! (Solved)] where drwr talks about StringStream so I tried using that by doing this:
self.pp = PNMImage()
if(base.win.getScreenshot(self.pp)):
self.pp = PNMImage(320, 240, self.pp.getNumChannels())
ss = StringStream()
self.pp.write(ss, 'jpeg')
self.ser.write(ss.getData())
Where self.ser is my serial connection.
Bytes of data do go across but I’m not sure if they are the jpeg, is there a way to send the StringStream data to a file so I can make sure getData() contains the image?
Or is there another Stream object I can use which is better suited? Or even a way to just pull the raw byte array from PNMImage?
Thanks for your time,
poncho