[Tutor] Print Screen

Luke Paireepinart rabidpoobear at gmail.com
Fri Nov 3 09:35:41 CET 2006

Chris Hengge wrote:
> Wow.. I have visions of writing a little wanna-be VNC client/server 
> now using the ImageGrab.grab() =D
> This ImageGrab trick does exactly what I wanted. Thanks for the tip!
> Actually, I want to write a little package for the learning experience 
> sometime over the holidays (plus I use VNC fairly often), but I can't 
> find any direction, or any already made packages for python for the 
> VNC protocol (no libs?). 
Heh, I was actually writing my own VNC, that's when I ran into the 
ImageGrab function.
I also did something cool, which is :
        self.prevscr = self.currscr
        self.currscr = ImageGrab.grab().resize((800,600))
        diff = ImageChops.difference(self.prevscr,self.currscr)

Obviously you need a currscr before you start, which I declared during 
the initialization of the class.
The cool part of this is that the ImageChops difference will return 
black pixels in any area of the screen that hasn't changed.
so you can just send the changed parts over the network (if you have a 
good algorithm to discard the unchanged portions).
Would be much faster than sending the whole screen every frame, obviously.
Not CPU-faster, but network-faster.

More information about the Tutor mailing list