Beispiel #1
0
        def get_screen_shot(self, antialias=False, rect=None):
            WIDTH, HEIGHT = self.get_screen_size()
            if rect:
                x, y, w, h = rect
                img = QPixmap.grabWindow(QApplication.desktop().winId(), x, y,
                                         w, h).toImage()
                WIDTH = w
                HEIGHT = h
            else:
                img = QPixmap.grabWindow(
                    QApplication.desktop().winId()).toImage()  # returns 32bits

            if self.HALFSIZE:
                length = (WIDTH / 2) * (HEIGHT / 2) * BPP
                ## note Qt.SmoothTransform only works on 32bit images
                if antialias:
                    img = img.scaled(QSize(WIDTH / 2, HEIGHT / 2),
                                     transformMode=Qt.SmoothTransformation)
                else:
                    img = img.scaled(QSize(WIDTH / 2, HEIGHT / 2))
                #img = img.convertToFormat( img.Format_RGB888 )	# WRONG!
                return ctypes.string_at(int(img.bits()), length)
            else:
                length = WIDTH * HEIGHT * BPP
                return ctypes.string_at(int(img.bits()), length)
Beispiel #2
0
		def get_screen_shot( self, antialias=False, rect=None ):
			WIDTH,HEIGHT = self.get_screen_size()
			if rect:
				x,y,w,h = rect
				img = QPixmap.grabWindow(QApplication.desktop().winId(), x,y,w,h).toImage()
				WIDTH = w; HEIGHT = h
			else:
				img = QPixmap.grabWindow(QApplication.desktop().winId()).toImage()	# returns 32bits

			if self.HALFSIZE:
				length = (WIDTH/2)*(HEIGHT/2)*BPP
				## note Qt.SmoothTransform only works on 32bit images
				if antialias: img = img.scaled( QSize(WIDTH/2, HEIGHT/2), transformMode=Qt.SmoothTransformation )
				else: img = img.scaled( QSize(WIDTH/2, HEIGHT/2) )
				#img = img.convertToFormat( img.Format_RGB888 )	# WRONG!
				return ctypes.string_at( int(img.bits()), length )
			else:
				length = WIDTH*HEIGHT*BPP
				return ctypes.string_at( int(img.bits()), length )
Beispiel #3
0
 def get_screen_size(self):
     _size = QApplication.desktop().size()
     WIDTH = _size.width()
     HEIGHT = _size.height()
     return WIDTH, HEIGHT
Beispiel #4
0
		def get_screen_size(self):
			_size = QApplication.desktop().size()
			WIDTH = _size.width()
			HEIGHT = _size.height()
			return WIDTH, HEIGHT