本文整理汇总了Python中mmfparser.bytereader.ByteReader类的典型用法代码示例。如果您正苦于以下问题:Python ByteReader类的具体用法?Python ByteReader怎么用?Python ByteReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ByteReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: write_fonts
def write_fonts(out, fonts):
fp = open(out, 'wb')
writer = ByteReader(fp)
writer.writeInt(len(fonts))
for font in fonts:
font.write(writer)
fp.close()
开发者ID:carriercomm,项目名称:anaconda,代码行数:7,代码来源:fontgen.py
示例2: convert
def convert(reader):
newReader = ByteReader()
for i in xrange(len(reader)):
value = reader.readByte(True)
value = ~(value - i % 256) % 256
newReader.writeByte(value, True)
newReader.seek(0)
return newReader
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:8,代码来源:flash.py
示例3: write_preload
def write_preload(self, images):
self.fp.seek(self.use_count_offset)
data = ByteReader()
for handle in images:
data.writeShort(handle, True)
for handle in xrange(self.image_count):
if handle in images:
continue
data.writeShort(handle, True)
self.fp.write(str(data))
开发者ID:tryzombie501,项目名称:anaconda,代码行数:10,代码来源:assets.py
示例4: get_shader
def get_shader(self, name, vert, frag):
writer = ByteReader()
writer.writeInt(len(vert))
writer.write(vert)
writer.writeInt(len(frag))
writer.write(frag)
return str(writer)
开发者ID:carriercomm,项目名称:anaconda,代码行数:7,代码来源:generic.py
示例5: read_runinfo
def read_runinfo(data):
info = {}
reader = ByteReader(data)
count = reader.readInt(True)
for _ in xrange(count):
name = reader.read(reader.readInt(True))
alts = {}
for i in xrange(26):
alts[i] = reader.readByte(True)
info[name] = alts
return info
开发者ID:joaormatos,项目名称:anaconda,代码行数:11,代码来源:runinfo.py
示例6: get_shader
def get_shader(self, name, vert, frag):
vert = translate_shader_data(vert, 'vertex', 'gles')
frag = translate_shader_data(frag, 'fragment', 'gles')
writer = ByteReader()
writer.writeInt(len(vert))
writer.write(vert)
writer.writeInt(len(frag))
writer.write(frag)
return str(writer)
开发者ID:carriercomm,项目名称:anaconda,代码行数:9,代码来源:html5.py
示例7: read
def read(self, reader):
self.handle = reader.readInt(True)
self.checksum = reader.readInt()
self.references = reader.readInt()
decompressedLenght = reader.readInt()
self.flags.setFlags(reader.readInt(True))
reserved = reader.readInt()
nameLenght = reader.readInt()
if self.settings.get('compressed', True):
size = reader.readInt()
data = ByteReader(zlib.decompress(reader.read(size)))
else:
data = reader.readReader(decompressedLenght)
self.name = self.readString(data, nameLenght)
self.data = data.read()
开发者ID:devinvisible,项目名称:anaconda,代码行数:15,代码来源:soundbank.py
示例8: write
def write(self, reader):
reader.writeShort(self.objectType)
reader.writeShort(self.num)
if self.objectType == 0 and self.num == 0:
return
dataReader = ByteReader()
if (self.objectType in expression_system
and self.num in expression_system[self.objectType]):
self.loader.write(dataReader)
elif self.objectType >= 2 or self.objectType == -7:
dataReader.writeShort(self.objectInfo, True)
dataReader.writeShort(self.objectInfoList)
if self.num in expression_extension:
self.loader.write(dataReader)
reader.writeShort(len(dataReader) + 6, True)
reader.writeReader(dataReader)
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:16,代码来源:all.py
示例9: read
def read(self, reader):
debug = self.settings.get('debug', False)
old = self.settings.get('old', False)
if debug:
path = reader.readString()
reader = ByteReader(open(path, 'rb'))
reader.skipBytes(4)
numberOfItems = reader.readInt()
if old:
klass = OldFont
else:
klass = FontItem
self.items = [self.new(klass, reader)
for _ in xrange(numberOfItems)]
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:17,代码来源:fontbank.py
示例10: Workspace
class Workspace(DataLoader):
name = ''
data = None
def initialize(self):
size = self.settings.get('defaultSize', 0)
self.data = ByteReader()
self.data.write('\x00' * size)
def read(self, reader):
self.name = reader.readString()
self.data = reader.readReader(reader.readInt(True))
def write(self, reader):
reader.writeString(self.name)
reader.writeInt(len(self.data))
reader.writeReader(self.data)
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:17,代码来源:binaryarray.py
示例11: compress
def compress(data):
reader = ByteReader()
compressed = zlib.compress(str(data))
reader.writeInt(len(data))
reader.writeInt(len(compressed))
reader.write(compressed)
return reader
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:7,代码来源:zlibdata.py
示例12: add_sound
def add_sound(self, name, ext=None, data=None):
if ext is None:
audio_type = NONE_TYPE
else:
audio_type = AUDIO_TYPES.get(ext, NATIVE_TYPE)
index = len(self.sounds)
sound_id = get_asset_name('SOUND', name, index)
self.sound_ids[name.lower()] = sound_id
self.header.putdefine(sound_id, index)
writer = ByteReader()
writer.writeInt(audio_type)
if data:
writer.writeIntString(data)
self.sounds.append(str(writer))
开发者ID:tryzombie501,项目名称:anaconda,代码行数:18,代码来源:assets.py
示例13: add_image
def add_image(self, hot_x, hot_y, act_x, act_y, data):
writer = ByteReader()
writer.writeShort(hot_x)
writer.writeShort(hot_y)
writer.writeShort(act_x)
writer.writeShort(act_y)
writer.writeIntString(data)
self.images.append(str(writer))
开发者ID:tryzombie501,项目名称:anaconda,代码行数:8,代码来源:assets.py
示例14: write_runinfo
def write_runinfo(info):
writer = ByteReader()
writer.writeInt(len(info), True)
for k, v in info.iteritems():
writer.writeInt(len(k), True)
writer.write(k)
for i in xrange(26):
reader.writeByte(v[i], True)
开发者ID:joaormatos,项目名称:anaconda,代码行数:8,代码来源:runinfo.py
示例15: get_shader
def get_shader(self, name, vert, frag):
vert_path = os.path.join(SHADERS_DIR, name + '.vsb')
frag_path = os.path.join(SHADERS_DIR, name + '.psb')
with open(vert_path, 'rb') as fp:
vert_data = fp.read()
with open(frag_path, 'rb') as fp:
frag_data = fp.read()
writer = ByteReader()
writer.writeInt(len(vert_data))
writer.write(vert_data)
writer.writeInt(len(frag_data))
writer.write(frag_data)
return str(writer)
开发者ID:joaormatos,项目名称:anaconda,代码行数:16,代码来源:d3d.py
示例16: read
def read(self, reader):
# reader.openEditor()
debug = self.settings.get('debug', False)
java = self.settings.get('java', False)
flash = self.settings.get('flash', False)
old = self.settings.get('old', False)
if debug:
path = reader.readString()
reader = ByteReader(open(path, 'rb'))
reader.skipBytes(4)
if java:
numberOfItems = reader.readShort()
itemsToRead = reader.readShort()
if flash:
itemClass = FlashSound
elif old:
itemClass = OldSound
else:
itemClass = JavaSound
else:
itemsToRead = reader.readInt()
if old:
itemClass = OldSound
else:
itemClass = SoundItem
compressed = not debug
self.items = [self.new(itemClass, reader, compressed = compressed)
for _ in xrange(itemsToRead)]
self.names = dict([(item.name, item) for item in self.items])
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:34,代码来源:soundbank.py
示例17: read
def read(self, reader):
debug = self.settings.get('debug', False)
old = self.settings.get('old', False)
if debug:
path = self.readString(reader)
reader = ByteReader(open(path, 'rb'))
reader.skipBytes(4)
numberOfItems = reader.readInt()
if old:
klass = OldFont
else:
klass = FontItem
offset = 0
if self.settings['build'] >= 284 and not debug:
offset = -1
self.items = []
for _ in xrange(numberOfItems):
item = self.new(klass, reader)
item.handle += offset
self.items.append(item)
开发者ID:carriercomm,项目名称:anaconda,代码行数:24,代码来源:fontbank.py
示例18: run
def run(self, cmd):
self.room = ByteReader(open(self.filename, 'rb'))
self.file_ver = self.room.readByte(True)
self.x_size = self.room.readByte(True)
self.y_size = self.room.readByte(True)
tileset_len = self.room.readByte(True)
self.tileset = self.room.readString(tileset_len)
self.tile_count = self.room.readInt(True)
image_path = os.path.join(SETS_PATH, '%s.png' % self.tileset)
image = Image.open(image_path).convert('RGBA')
col = image.getpixel((0, 0))
self.tileset_transparent = col[:3]
if col[3] == 255:
print 'Filtering image with transparent color', col
buf = image.load()
for y in xrange(image.size[1]):
for x in xrange(image.size[0]):
test_col = buf[(x, y)]
if test_col != col:
continue
buf[(x, y)] = (0, 0, 0, 0)
frame = self.mfa.frames[0]
if cmd == 'extract_tiles':
self.run_extract_tiles(image)
return
elif cmd == 'build':
self.run_build(image)
frame.folders = []
for item in frame.items:
folder = frame.new(ItemFolder)
folder.items = [item.handle]
frame.folders.append(folder)
basename = os.path.basename(self.filename)
out_name = os.path.splitext(basename)[0] + '.mfa'
out_path = os.path.join(self.outdir, out_name)
if os.path.isfile(out_path):
os.remove(out_path)
self.mfa.write(ByteReader(open(out_path, 'wb')))
print 'Created %s' % out_name
开发者ID:carriercomm,项目名称:anaconda,代码行数:46,代码来源:roombuilder.py
示例19: write
def write(self, reader):
java = self.settings.get('java', False)
debug = self.settings.get('debug', False)
compressed = not debug and self.settings.get('compressed', True)
reader.writeInt(self.handle, True)
compressedReader = ByteReader()
compressedReader.writeInt(self.checksum)
compressedReader.writeInt(self.references)
compressedReader.writeInt(0) # size
self.value.write(compressedReader)
if not java and compressed:
reader.writeReader(zlibdata.compress(compressedReader))
else:
reader.writeReader(compressedReader)
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:17,代码来源:fontbank.py
示例20: read
def read(self, filename):
self.points = []
try:
data = ByteReader(open(filename, 'rb'))
except IOError:
return
while data.tell() < len(data):
count = (data.readInt() - 2) / 2
x = data.readInt()
y = data.readInt()
point = Point(x, y)
self.points.append(point)
for _ in xrange(count):
point_id = data.readInt()
distance = data.readFloat()
connection = Connection(point_id, distance)
point.connections.append(connection)
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:17,代码来源:AdvPathMov.py
注:本文中的mmfparser.bytereader.ByteReader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论