本文整理汇总了Python中PyQt4.QtCore.qUncompress方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.qUncompress方法的具体用法?Python QtCore.qUncompress怎么用?Python QtCore.qUncompress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore
的用法示例。
在下文中一共展示了QtCore.qUncompress方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: processEndElement
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qUncompress [as 别名]
def processEndElement(self):
name=self.xml.name()
if name == 'toolevent':
#print "Adding end tool event to queue on layer", self.curlayer
self.window.addPenUpToQueue(self.curlayer,self.lastx,self.lasty,type)
self.curtool=None
elif name == 'rawevent':
return
self.inrawevent=False
# convert data out of base 64 then uncompress
data=qtcore.QByteArray()
print "%s" % self.rawstring
data=data.append(self.rawstring)
data=qtcore.QByteArray.fromBase64(data)
data=qtcore.qUncompress(data)
image=qtgui.QImage()
image.loadFromData(data,"PNG")
self.window.addRawEventToQueue(self.layerkey,image,self.x,self.y,None,type)
elif name == 'clippath':
poly=qtgui.QPolygonF(self.clippoints)
self.curtool.clippath=qtgui.QPainterPath()
self.curtool.clippath.addPolygon(poly)
示例2: init_css
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qUncompress [as 别名]
def init_css(self):
'''
# ensure that css files are up to date.we have a css file..
# otherwise the layout will be awful!
'''
CommonSettings.init_css(self)
for css in ("notes", "details"):
resource = QtCore.QResource(":css/%s.css"% css)
if resource.isCompressed():
data = QtCore.qUncompress(resource.data())
else:
data = resource.data()
default_loc = os.path.join(self.LOCALFOLDER, "%s.css"% css)
try:
f = open(default_loc, "r")
css_data = f.read()
f.close()
if css_data == data:
LOGGER.debug("%s is current"% default_loc)
continue
except IOError:
pass
print "initiating a new css file - %s"% default_loc
f = open(default_loc, "w")
f.write(data)
f.close()
示例3: processCharacterData
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qUncompress [as 别名]
def processCharacterData(self):
if self.imagestarted:
#print_debug("processing image data")
self.imagestarted=False
rawstring=self.xml.text().toString()
data=qtcore.QByteArray()
data=data.append(rawstring)
data=qtcore.QByteArray.fromBase64(data)
data=qtcore.qUncompress(data)
self.image=qtgui.QImage.fromData(data,"PNG")
示例4: getScene
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qUncompress [as 别名]
def getScene(self):
instr = QtCore.QDataStream(self.tcpSocket)
instr.setVersion(QtCore.QDataStream.Qt_4_0)
while True:
if self.blockSize == 0:
if self.tcpSocket.bytesAvailable() < 4:
return
self.blockSize = instr.readUInt32()
if self.tcpSocket.bytesAvailable() < self.blockSize:
return
self.blockSize = 0
pix = QtGui.QImage()
ba = QtCore.QByteArray()
instr >> ba
if self.tcpSocket.bytesAvailable() > 0:
rospy.logdebug("Image dropped")
continue
ba = QtCore.qUncompress(ba)
if not pix.loadFromData(ba):
rospy.logerr("Failed to load image from received data")
if not self.is_calibrated() or self.calibrating:
return
img = pix.convertToFormat(QtGui.QImage.Format_ARGB32)
v = qimage2ndarray.rgb_view(img)
# TODO gpu
image_np = cv2.warpPerspective(
v, self.h_matrix, (self.width(), self.height())
) # , flags = cv2.INTER_LINEAR
height, width, channel = image_np.shape
bytesPerLine = 3 * width
image = QtGui.QPixmap.fromImage(
QtGui.QImage(image_np.data, width, height, bytesPerLine, QtGui.QImage.Format_RGB888)
)
self.pix_label.setPixmap(image)
self.update()
return
示例5: __init__
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qUncompress [as 别名]
def __init__(self, replayfile):
replay = open(inFile, "rt")
info = json.loads(replay.readline())
self.bin = QtCore.qUncompress(QtCore.QByteArray.fromBase64(replay.read()))
replay.close()
#f = open(inFile, 'rb')
#self.bin = f.read()
self.offset= 0
self.supcomVersion = ""
self.replayVersion = ""
self.players = []
示例6: processStartElement
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qUncompress [as 别名]
def processStartElement(self):
name=self.xml.name()
attrs=self.xml.attributes()
if name == 'createdoc':
(width,ok)=attrs.value('width').toString().toInt()
(height,ok)=attrs.value('height').toString().toInt()
self.window.addSetCanvasSizeRequestToQueue(width,height,type)
elif name == 'addlayer':
(pos,ok)=attrs.value("position").toString().toInt()
(key,ok)=attrs.value("key").toString().toInt()
(owner,ok)=attrs.value("owner").toString().toInt()
print "got owner from xml as:", owner
dockey=self.window.nextLayerKey()
self.window.addInsertLayerEventToQueue(pos,dockey,"animation",self.type,owner=owner)
self.addKeyTranslation(key,dockey)
elif name == 'sublayer':
(key,ok)=attrs.value("index").toString().toInt()
self.window.addRemoveLayerRequestToQueue(key,type)
elif name == 'movelayer':
(change,ok)=attrs.value("change").toString().toInt()
(index,ok)=attrs.value("index").toString().toInt()
if change==1:
self.window.addLayerUpToQueue(index,type)
else:
self.window.addLayerDownToQueue(index,type)
elif name == 'layeralpha':
(key,ok)=attrs.value("key").string.toInt()
self.window.addOpacityChangeToQueue(key,attrs.value("alpha").toString().toFloat(),type)
elif name == 'layermode':
time.sleep(self.stepdelay)
(index,ok)=attrs.value('index').toString().toInt()
mode=BlendTranslations.intToMode(attrs.value('mode').toString().toInt())
self.window.addBlendModeChangeToQueue(self.translateKey(index),mode,type)
elif name == 'toolevent':
self.strokestart=False
toolname="%s" % attrs.value('name').toString()
(layerkey,ok)=attrs.value('layerkey').toString().toInt()
self.curlayer=self.translateKey(layerkey)
tool=self.window.master.getToolClassByName(toolname.strip())
# print error if we can't find the tool
if tool == None:
print "Error, couldn't find tool with name: ", toolname
return
self.curtool=tool.setupTool(self.window)
self.curtool.layerkey=self.curlayer
elif name == 'fgcolor':
(r,ok)=attrs.value('r').toString().toInt()
(g,ok)=attrs.value('g').toString().toInt()
(b,ok)=attrs.value('b').toString().toInt()
self.curtool.fgcolor=qtgui.QColor(r,g,b)
elif name == 'bgcolor':
(r,ok)=attrs.value('r').toString().toInt()
(g,ok)=attrs.value('g').toString().toInt()
(b,ok)=attrs.value('b').toString().toInt()
self.curtool.bgcolor=qtgui.QColor(r,g,b)
elif name == 'clippath':
self.clippoints=[]
elif name == 'polypoint':
(x,ok)=attrs.value('x').toString().toInt()
(y,ok)=attrs.value('y').toString().toInt()
self.clippoints.append(qtcore.QPointF(x,y))
elif name == 'toolparam':
(value,ok)=attrs.value('value').toString().toInt()
self.curtool.setOption(attrs.value('name'),value)
elif name == 'rawevent':
self.inrawevent=True
self.raweventargs=[]
(self.x,ok)=attrs.value('x').toString().toInt()
(self.y,ok)=attrs.value('y').toString().toInt()
(layerkey,ok)=attrs.value('layerkey').toString().toInt()
self.layerkey=self.translateKey(layerkey)
self.rawstring=self.xml.readElementText()
data=qtcore.QByteArray()
data=data.append(self.rawstring)
data=qtcore.QByteArray.fromBase64(data)
data=qtcore.qUncompress(data)
image=qtgui.QImage()
image.loadFromData(data,"PNG")
self.window.addRawEventToQueue(self.layerkey,image,self.x,self.y,None,type)
elif name == 'point':
time.sleep(self.stepdelay)
(x,ok)=attrs.value('x').toString().toFloat()
(y,ok)=attrs.value('y').toString().toFloat()
#.........这里部分代码省略.........
示例7: replay
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qUncompress [as 别名]
def replay(source, detach=False):
'''
Launches FA streaming the replay from the given location. Source can be a QUrl or a string
'''
logger.info("fa.exe.replay(" + str(source) + ", detach = " + str(detach))
if fa.instance.available():
version = None
featured_mod_versions = None
arg_string = None
replay_id = None
# Convert strings to URLs
if isinstance(source, basestring):
if os.path.isfile(source):
if source.endswith(".fafreplay"): # the new way of doing things
replay = open(source, "rt")
info = json.loads(replay.readline())
binary = QtCore.qUncompress(QtCore.QByteArray.fromBase64(replay.read()))
logger.info("Extracted " + str(binary.size()) + " bytes of binary data from .fafreplay.")
replay.close()
if binary.size() == 0:
logger.info("Invalid replay")
QtGui.QMessageBox.critical(None, "FA Forever Replay", "Sorry, this replay is corrupted.")
return False
scfa_replay = QtCore.QFile(os.path.join(util.CACHE_DIR, "temp.scfareplay"))
scfa_replay.open(QtCore.QIODevice.WriteOnly | QtCore.QIODevice.Truncate)
scfa_replay.write(binary)
scfa_replay.flush()
scfa_replay.close()
mapname = info.get('mapname', None)
mod = info['featured_mod']
replay_id = info['uid']
featured_mod_versions = info.get('featured_mod_versions', None)
arg_string = scfa_replay.fileName()
parser = replayParser(arg_string)
version = parser.getVersion()
elif source.endswith(".scfareplay"): # compatibility mode
filename = os.path.basename(source)
if len(filename.split(".")) > 2:
mod = filename.rsplit(".", 2)[1]
logger.info("mod guessed from " + source + " is " + mod)
else:
mod = "faf" #TODO: maybe offer a list of mods for the user.
logger.warn("no mod could be guessed, using fallback ('faf') ")
mapname = None
arg_string = source
parser = replayParser(arg_string)
version = parser.getVersion()
else:
QtGui.QMessageBox.critical(None, "FA Forever Replay",
"Sorry, FAF has no idea how to replay this file:<br/><b>" + source + "</b>")
logger.info("Replaying " + str(arg_string) + " with mod " + str(mod) + " on map " + str(mapname))
#Wrap up file path in "" to ensure proper parsing by FA.exe
arg_string = '"' + arg_string + '"'
else:
source = QtCore.QUrl(
source) #Try to interpret the string as an actual url, it may come from the command line
if isinstance(source, QtCore.QUrl):
url = source
# Determine if it's a faflive url
if url.scheme() == "faflive":
mod = url.queryItemValue("mod")
mapname = url.queryItemValue("map")
replay_id = url.path().split("/")[0]
# whip the URL into shape so ForgedAllianceForever.exe understands it
arg_url = QtCore.QUrl(url)
arg_url.setScheme("gpgnet")
arg_url.setEncodedQuery(QtCore.QByteArray())
arg_string = arg_url.toString()
else:
QtGui.QMessageBox.critical(None, "FA Forever Replay",
"App doesn't know how to play replays from that scheme:<br/><b>" + url.scheme() + "</b>")
return False
# We couldn't construct a decent argument format to tell ForgedAlliance for this replay
if not arg_string:
QtGui.QMessageBox.critical(None, "FA Forever Replay",
"App doesn't know how to play replays from that source:<br/><b>" + str(
source) + "</b>")
return False
# Launch preparation: Start with an empty arguments list
arguments = ['/replay', arg_string]
#Proper mod loading code
mod = "faf" if mod == "ladder1v1" else mod
if '/init' not in arguments:
arguments.append('/init')
#.........这里部分代码省略.........
示例8: print_radarinfo
# 需要导入模块: from PyQt4 import QtCore [as 别名]
# 或者: from PyQt4.QtCore import qUncompress [as 别名]
try:
scan, radarinfo = root.getchildren()
except ValueError:
scan, radarinfo, history = root.getchildren()
print_radarinfo(radarinfo)
slice = scan.findall('slice')
tipoArchivo= print_slice(slice)
print 'Tipo Archivo:'+tipoArchivo
print 'BLOBS: %i' % len(blobs)
bandas = []
grados = []
for i,bl in enumerate(blobs):
up=QtCore.qUncompress(bl)
if i % 2 == 0:
print 'Blob',i,len(up) - bins,azimth*bins,len(up) - bins==azimth*bins
startangle, grados = get_angulos(up)
if i % 2 <> 0:
print 'Blob',i,len(up) - bins,azimth*bins,len(up) - bins==azimth*bins
if tipoArchivo in ['KDP','PhiDP']:
blobs_img = get_matriz_vol_16b(up, tipoArchivo)
else:
blobs_img = get_matriz_vol(up, tipoArchivo)