当前位置: 首页>>代码示例>>Python>>正文


Python QPixmap.grabWindow方法代码示例

本文整理汇总了Python中PySide.QtGui.QPixmap.grabWindow方法的典型用法代码示例。如果您正苦于以下问题:Python QPixmap.grabWindow方法的具体用法?Python QPixmap.grabWindow怎么用?Python QPixmap.grabWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QPixmap的用法示例。


在下文中一共展示了QPixmap.grabWindow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sendLocation

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import grabWindow [as 别名]
	def sendLocation(self, jid, latitude, longitude, rotate):
		latitude = latitude[:10]
		longitude = longitude[:10]

		self._d("Capturing preview...")
		QPixmap.grabWindow(QApplication.desktop().winId()).save(WAConstants.CACHE_PATH+"/tempimg.png", "PNG")
		img = QImage(WAConstants.CACHE_PATH+"/tempimg.png")

		if rotate == "true":
			rot = QTransform()
			rot = rot.rotate(90)
			img = img.transformed(rot)

		if img.height() > img.width():
			result = img.scaledToWidth(320,Qt.SmoothTransformation);
			result = result.copy(result.width()/2-50,result.height()/2-50,100,100);
		elif img.height() < img.width():
			result = img.scaledToHeight(320,Qt.SmoothTransformation);
			result = result.copy(result.width()/2-50,result.height()/2-50,100,100);
		#result = img.scaled(96, 96, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation);

		result.save( WAConstants.CACHE_PATH+"/tempimg2.jpg", "JPG" );

		f = open(WAConstants.CACHE_PATH+"/tempimg2.jpg", 'r')
		stream = base64.b64encode(f.read())
		f.close()


		os.remove(WAConstants.CACHE_PATH+"/tempimg.png")
		os.remove(WAConstants.CACHE_PATH+"/tempimg2.jpg")

		fmsg = WAXMPP.message_store.createMessage(jid);
		
		mediaItem = WAXMPP.message_store.store.Media.create()
		mediaItem.mediatype_id = WAConstants.MEDIA_TYPE_LOCATION
		mediaItem.remote_url = None
		mediaItem.preview = stream
		mediaItem.local_path ="%s,%s"%(latitude,longitude)
		mediaItem.transfer_status = 2

		fmsg.content = QtCore.QCoreApplication.translate("WAEventHandler", "Location")
		fmsg.Media = mediaItem

		if fmsg.Conversation.type == "group":
			contact = WAXMPP.message_store.store.Contact.getOrCreateContactByJid(self.conn.jid)
			fmsg.setContact(contact);
		
		fmsg.setData({"status":0,"content":fmsg.content,"type":1})
		WAXMPP.message_store.pushMessage(jid,fmsg)
		
		
		resultId = self.interfaceHandler.call("message_locationSend", (jid, latitude, longitude, stream))
		k = Key(jid, True, resultId)
		fmsg.key = k.toString()
		fmsg.save()
开发者ID:timofonic,项目名称:wazapp,代码行数:57,代码来源:waxmpp.py

示例2: grabImg

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import grabWindow [as 别名]
	def grabImg(self):
		self.idFrame += 1	
		wid = QApplication.desktop().winId()
		QPixmap.grabWindow(wid, self.screenArea.x, self.screenArea.y, self.screenArea.w, self.screenArea.h).save(self.buffer, 'png')
		strio = StringIO.StringIO()
		strio.write(self.buffer.data())
		self.buffer.seek(0)
		strio.seek(0)
		pix = np.array(Image.open(strio))
		pix = cv2.resize(pix, (0,0), fx=self.scale, fy=self.scale)
		real_color = cv2.cvtColor(pix, cv2.COLOR_BGR2RGB)
		return real_color
开发者ID:guyver2,项目名称:SFA2YT,代码行数:14,代码来源:Player.py

示例3: shoot

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import grabWindow [as 别名]
def shoot():
    if( not isTokenCollected()):
        redirect_to_permission_page()

    #taking the screenshot
    filename = date.strftime('%Y-%m-%d_%H-%M-%S.jpg')
    p = QPixmap.grabWindow(QApplication.desktop().winId())
    p.save(filename, 'jpg')
    upload_file_to_drive(filename)
开发者ID:gitter-badger,项目名称:SHTR.proto,代码行数:11,代码来源:shoot.py

示例4: _get_screen_graphics

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import grabWindow [as 别名]
    def _get_screen_graphics ( self ):
        from facets.ui.toolkit import toolkit

        if self._screen_graphics is None:
            control = self.control
            pixmap  = QPixmap.grabWindow( control.winId() )
            self._sg_control = sg = toolkit().create_control( self )
            sg._pixmap = pixmap
            dx, dy     = self.size
            sg.bounds  = ( 0, 0, dx, dy )
            sg.set_event_handler( paint = self._screen_graphics_paint )
            painter = painter_for( pixmap )
            painter._control = sg.control
            self._screen_graphics = (
                QtGraphics( painter, bitmap = pixmap ), 0, 0
            )

        return self._screen_graphics
开发者ID:davidmorrill,项目名称:facets,代码行数:20,代码来源:control.py

示例5: capture

# 需要导入模块: from PySide.QtGui import QPixmap [as 别名]
# 或者: from PySide.QtGui.QPixmap import grabWindow [as 别名]
    def capture(self):
        app.processEvents()

        print "caught capture",('tmp_{}_{:'+self.fmt+'}.jpg').format(self.UID,self.capture_count)
        print "current fps",float(self.capture_count)/(time.time()-self.start_capture_time)
        if not self.snap_shots.queue.empty():
            self.snap_shots.queue.get(0)
            arrow = QPixmap(self.arrow_icon);
            self.px = QPixmap.grabWindow(QApplication.desktop().winId())
            painter = QPainter(self.px)
            painter.drawPixmap(QCursor.pos(), arrow)
            if(self.options.capture_area_sa.isChecked()):
                self.px2 = self.px.copy(self.options.sa_x.value(),
                                        self.options.sa_y.value(),
                                        self.options.sa_w.value(),
                                        self.options.sa_h.value())
            else:
                self.px2 = self.px
            self.px2.save(('tmp_{}_{:'+self.fmt+'}.jpg').format(self.UID,self.capture_count), 'jpg')
            self.capture_count+=1
开发者ID:marcrobinson,项目名称:marcrobinson.github.io,代码行数:22,代码来源:capture.py


注:本文中的PySide.QtGui.QPixmap.grabWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。