本文整理汇总了Python中PyQt5.QtCore.QByteArray.count方法的典型用法代码示例。如果您正苦于以下问题:Python QByteArray.count方法的具体用法?Python QByteArray.count怎么用?Python QByteArray.count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QByteArray
的用法示例。
在下文中一共展示了QByteArray.count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read
# 需要导入模块: from PyQt5.QtCore import QByteArray [as 别名]
# 或者: from PyQt5.QtCore.QByteArray import count [as 别名]
def read(self, fileName):
uncompressed = QByteArray()
# Read data
f = QFile(fileName)
if (f.open(QIODevice.ReadOnly)) :
compressed = f.readAll()
f.close()
uncompressed, length = decompress(compressed, 48 * 48)
# Check the data
if (uncompressed.count() != 48 * 48) :
self.mError = self.tr("This is not a valid Droidcraft map file!")
return None
uncompressed = uncompressed.data()
# Build 48 x 48 map
# Create a Map -> Create a Tileset -> Add Tileset to map
# -> Create a TileLayer -> Fill layer -> Add TileLayer to Map
map = Map(Map.Orientation.Orthogonal, 48, 48, 32, 32)
mapTileset = Tileset.create("tileset", 32, 32)
mapTileset.loadFromImage(QImage(":/tileset.png"), "tileset.png")
map.addTileset(mapTileset)
# Fill layer
mapLayer = TileLayer("map", 0, 0, 48, 48)
# Load
for i in range(0, 48 * 48):
tileFile = int(uncompressed[i])&0xff
y = int(i / 48)
x = i - (48 * y)
tile = mapTileset.tileAt(tileFile)
mapLayer.setCell(x, y, Cell(tile))
map.addLayer(mapLayer)
return map